Skip to content
PHP Ecosystem
Explore

HasClass

API reference › HTML Attribute › Global › HasClass

traitUIAwesome\Html\Attribute\Global\HasClass
Sourcesrc/Global/HasClass.php
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.

MethodDescriptionDefined by
class()Sets the class attribute.HasClass
public function class(string|Stringable|UnitEnum|null $value, bool $override = false): static

Sets the class attribute.

Parameters

ParameterTypeDescription
$valuestring|Stringable|UnitEnum|nullCSS class value, or null to remove the attribute.
$overrideboolWhether to override existing classes (true) or merge (false).

Returns

static: New instance with the updated class attribute.