# HasAutocapitalize

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

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

Used by 2 types:

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

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

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

## Methods

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

## Method details

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

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

Sets the `autocapitalize` attribute.

**Parameters**

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

**Returns**

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

**Throws**

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