HasClass
API reference › HTML Attribute › Global › HasClass
Used by 4 types
Provides an immutable API for the class attribute.
See also: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
class() | Sets the class attribute. | HasClass |
Method details
Section titled “Method details”class()
Section titled “class() ”public function class(string|Stringable|UnitEnum|null $value, bool $override = false): staticSets the class attribute.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | string|Stringable|UnitEnum| | CSS class value, or null to remove the attribute. |
$override | bool | Whether to override existing classes (true) or merge (false). |
Returns
static: New instance with the updated class attribute.