# HasContentEditable

> Provides an immutable API for the contenteditable attribute.

[API reference](/docs/api/index.md) › [HTML Attribute](/docs/extensions/html-attribute/reference/index.md) › [Global](/docs/extensions/html-attribute/reference/global/index.md) › HasContentEditable

| trait | `UIAwesome\Html\Attribute\Global\HasContentEditable` |
| --- | --- |
| Source | [`src/Global/HasContentEditable.php`](https://github.com/ui-awesome/html-attribute/blob/main/src/Global/HasContentEditable.php#L21) |

Used by 1 type:

- [`UIAwesome\Html\Core\Element\BaseBlock`](/docs/extensions/html-core/reference/element/baseblock/index.md)

Provides an immutable API for the `contenteditable` attribute.

See also: <https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/contenteditable>.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`contentEditable()`](#method-contentEditable) | Sets the `contenteditable` attribute. | `HasContentEditable` |

## Method details

### contentEditable() <span id="method-contentEditable"></span>

```php
public function contentEditable(bool|string|UnitEnum|null $value): static
```

Sets the `contenteditable` attribute.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `bool\|string\|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php)`\|null` | Content editability value. Use `true`, `false`, or 'plaintext-only', or `null` to remove the attribute. |

**Returns**

`static`: New instance with the updated `contenteditable` attribute. [`ContentEditable`](/docs/extensions/html-attribute/reference/values/contenteditable/index.md) for predefined enum values.

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): If the value is not valid.