Skip to content
PHP Ecosystem
Explore

HasContainerCollection

API reference › HTML Mixin › HasContainerCollection

traitUIAwesome\Html\Mixin\HasContainerCollection
Sourcesrc/HasContainerCollection.php

Provides an immutable API for managing the container element and its attributes.

PropertyTypeDescriptionDefined by
$container protectedboolWhether to render the container. Default: false.HasContainerCollection
$containerAttributes protectedarrayHTML attributes array for the container element. Default: [].HasContainerCollection
$containerTag protectedfalse|UnitEnumTag name for the container element, or false to disable. Default: false.HasContainerCollection
MethodDescriptionDefined by
container()Sets whether to render the container.HasContainerCollection
containerAttributes()Sets the container attributes.HasContainerCollection
containerClass()Adds a CSS class to the container element attributes.HasContainerCollection
containerRemoveAttribute()Removes a specific HTML attribute from the container element.HasContainerCollection
containerSetAttribute()Sets a single HTML attribute for the container element.HasContainerCollection
containerTag()Sets the container tag name.HasContainerCollection
getContainerAttribute()Returns the value of a single HTML attribute for the container element attributes.HasContainerCollection
getContainerAttributes()Returns the array of HTML attributes for the container element.HasContainerCollection
getContainerTag()Returns the tag name for the container element.HasContainerCollection
isContainer()Returns whether the container element should be rendered.HasContainerCollection
public function container(bool $value): static

Sets whether to render the container.

Parameters

ParameterTypeDescription
$valueboolSet to true to render the container element, or false to skip rendering.

Returns

static: New instance with the updated container value.

public function containerAttributes(array $attributes): static

Sets the container attributes.

Parameters

ParameterTypeDescription
$attributesarrayArray of attributes to apply to the container element.

Returns

static: New instance with the updated containerAttributes value.

public function containerClass(string|Stringable|UnitEnum|null $value, bool $override = false): static

Adds a CSS class to the container element attributes.

Parameters

ParameterTypeDescription
$valuestring|Stringable|UnitEnum|nullCSS class name to add.
$overrideboolWhether to override existing class value.

Returns

static: New instance with the updated containerAttributes value.

public function containerRemoveAttribute(string|UnitEnum $key): static

Removes a specific HTML attribute from the container element.

Parameters

ParameterTypeDescription
$keystring|UnitEnumAttribute name to remove.

Returns

static: New instance without the specified container attribute.

public function containerSetAttribute(string|UnitEnum $key, mixed $value): static

Sets a single HTML attribute for the container element.

Parameters

ParameterTypeDescription
$keystring|UnitEnumAttribute name.
$valuemixedAttribute value.

Returns

static: New instance with the updated containerAttributes value.

public function containerTag(false|UnitEnum $value): static

Sets the container tag name.

Parameters

ParameterTypeDescription
$valuefalse|UnitEnumTag name for the container element, or false to disable.

Returns

static: New instance with the updated containerTag value.

public function getContainerAttribute(string|UnitEnum $key, mixed $default = null): mixed

Returns the value of a single HTML attribute for the container element attributes.

Parameters

ParameterTypeDescription
$keystring|UnitEnumAttribute name.
$defaultmixedDefault value when the attribute is missing.

Returns

mixed: Attribute value or default.

public function getContainerAttributes(): array

Returns the array of HTML attributes for the container element.

Returns

array: Attributes array assigned to the container element.

public function getContainerTag(): false|UnitEnum

Returns the tag name for the container element.

Returns

false|UnitEnum: Tag name for the container element, or false to disable.

public function isContainer(): bool

Returns whether the container element should be rendered.

Returns

bool: true if the container element should be rendered, or false to skip rendering.