# HasValue

> Provides an immutable API for the value attribute.

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

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

Used by 20 types:

- [`UIAwesome\Html\Form\AbstractInputDateTime`](/docs/extensions/html/reference/form/abstractinputdatetime/index.md)
- [`UIAwesome\Html\Form\Button`](/docs/extensions/html/reference/form/button/index.md)
- [`UIAwesome\Html\Form\InputCheckbox`](/docs/extensions/html/reference/form/inputcheckbox/index.md)
- [`UIAwesome\Html\Form\InputColor`](/docs/extensions/html/reference/form/inputcolor/index.md)
- [`UIAwesome\Html\Form\InputEmail`](/docs/extensions/html/reference/form/inputemail/index.md)
- [`UIAwesome\Html\Form\InputHidden`](/docs/extensions/html/reference/form/inputhidden/index.md)
- [`UIAwesome\Html\Form\InputNumber`](/docs/extensions/html/reference/form/inputnumber/index.md)
- [`UIAwesome\Html\Form\InputPassword`](/docs/extensions/html/reference/form/inputpassword/index.md)
- [`UIAwesome\Html\Form\InputRadio`](/docs/extensions/html/reference/form/inputradio/index.md)
- [`UIAwesome\Html\Form\InputRange`](/docs/extensions/html/reference/form/inputrange/index.md)
- [`UIAwesome\Html\Form\InputReset`](/docs/extensions/html/reference/form/inputreset/index.md)
- [`UIAwesome\Html\Form\InputSearch`](/docs/extensions/html/reference/form/inputsearch/index.md)
- [`UIAwesome\Html\Form\InputSubmit`](/docs/extensions/html/reference/form/inputsubmit/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\Meter`](/docs/extensions/html/reference/form/meter/index.md)
- [`UIAwesome\Html\Form\Option`](/docs/extensions/html/reference/form/option/index.md)
- [`UIAwesome\Html\Form\Progress`](/docs/extensions/html/reference/form/progress/index.md)
- [`UIAwesome\Html\List\Li`](/docs/extensions/html/reference/list/li/index.md)

Provides an immutable API for the `value` attribute.

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

## Methods

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

## Method details

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

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

Sets the `value` attribute.

Defines the current value for the element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `bool\|float\|int\|string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php)`\|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php)`\|null` | Element value as bool, int, float, string, Stringable, UnitEnum, or `null` to remove the attribute. |

**Returns**

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