# HasPlaceholder

> Provides an immutable API for the placeholder 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) › HasPlaceholder

| trait | `UIAwesome\Html\Form\Mixin\HasPlaceholder` |
| --- | --- |
| Source | [`src/Form/Mixin/HasPlaceholder.php`](https://github.com/ui-awesome/html/blob/main/src/Form/Mixin/HasPlaceholder.php#L21) |

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\TextArea`](/docs/extensions/html/reference/form/textarea/index.md)

Provides an immutable API for the `placeholder` attribute.

Satisfies [`PlaceholderInterface`](/docs/extensions/html-contracts/reference/form/placeholderinterface/index.md) for the controls that declare it.

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

## Methods

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

## Method details

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

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

Sets the `placeholder` 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` | Placeholder text, or `null` to remove the attribute. |

**Returns**

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