# HasAutocorrect

> Provides an immutable API for the HTML autocorrect 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) › HasAutocorrect

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

Used by 1 type:

- [`UIAwesome\Html\Form\TextArea`](/docs/extensions/html/reference/form/textarea/index.md)

Provides an immutable API for the HTML `autocorrect` attribute.

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

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`autocorrect()`](#method-autocorrect) | Sets the `autocorrect` attribute. | `HasAutocorrect` |

## Method details

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

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

Sets the `autocorrect` attribute.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string\|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php)`\|null` | Autocorrect behavior ('on' or 'off'), or `null` to remove the attribute. |

**Returns**

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

**Throws**

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