# HasLabel

> Provides an immutable API for the label attribute.

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

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

Used by 3 types:

- [`UIAwesome\Html\Embedded\Track`](/docs/extensions/html/reference/embedded/track/index.md)
- [`UIAwesome\Html\Form\Optgroup`](/docs/extensions/html/reference/form/optgroup/index.md)
- [`UIAwesome\Html\Form\Option`](/docs/extensions/html/reference/form/option/index.md)

Provides an immutable API for the `label` attribute.

See also: <https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/option#label>.

## Methods

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

## Method details

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

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

Sets the `label` attribute.

**Parameters**

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

**Returns**

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