# HasSize

> Provides an immutable API for the size attribute.

[API reference](/docs/api/index.md) › [HTML](/docs/extensions/html/reference/index.md) › [Form](/docs/extensions/html/reference/form/index.md) › [Mixin](/docs/extensions/html/reference/form/mixin/index.md) › HasSize

| trait | `UIAwesome\Html\Form\Mixin\HasSize` |
| --- | --- |
| Uses traits | [`HasIntLikeAttribute`](/docs/extensions/html/reference/form/mixin/hasintlikeattribute/index.md) |
| Source | [`src/Form/Mixin/HasSize.php`](https://github.com/ui-awesome/html/blob/main/src/Form/Mixin/HasSize.php#L19) |

Used by 7 types:

- [`UIAwesome\Html\Form\InputEmail`](/docs/extensions/html/reference/form/inputemail/index.md)
- [`UIAwesome\Html\Form\InputPassword`](/docs/extensions/html/reference/form/inputpassword/index.md)
- [`UIAwesome\Html\Form\InputSearch`](/docs/extensions/html/reference/form/inputsearch/index.md)
- [`UIAwesome\Html\Form\InputTel`](/docs/extensions/html/reference/form/inputtel/index.md)
- [`UIAwesome\Html\Form\InputText`](/docs/extensions/html/reference/form/inputtext/index.md)
- [`UIAwesome\Html\Form\InputUrl`](/docs/extensions/html/reference/form/inputurl/index.md)
- [`UIAwesome\Html\Form\Select`](/docs/extensions/html/reference/form/select/index.md)

Provides an immutable API for the `size` attribute.

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

## Methods

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

## Method details

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

```php
public function size(int|string|Stringable|UnitEnum|null $value): static
```

Sets the `size` attribute.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `int\|string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php)`\|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php)`\|null` | Size value. Must be '>= 0', or `null` to remove the attribute. |

**Returns**

`static`: New instance with the updated `size` attribute.

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): if the value is not an integer-like value '>= 0'.