HasRole
API reference › HTML Attribute › Global › HasRole
Used by 4 types
Provides an immutable API for the role attribute.
See also: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
role() | Sets the role attribute. | HasRole |
Method details
Section titled “Method details”role()
Section titled “role() ”public function role(string|Stringable|UnitEnum|null $value): staticSets the role attribute.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | string|Stringable|UnitEnum| | ARIA role, or null to remove the attribute. |
Returns
static: New instance with the updated role attribute. Role for predefined enum values.
Throws
InvalidArgumentException: If the value is not valid.