HasContainerCollection
API reference › HTML Mixin › HasContainerCollection
Provides an immutable API for managing the container element and its attributes.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$container protected | bool | Whether to render the container. Default: false. | HasContainerCollection |
$containerAttributes protected | array | HTML attributes array for the container element. Default: []. | HasContainerCollection |
$containerTag protected | false|UnitEnum | Tag name for the container element, or false to disable. Default: false. | HasContainerCollection |
Methods
Section titled “Methods”| Method | Description | Defined 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 |
Method details
Section titled “Method details”container()
Section titled “container() ”public function container(bool $value): staticSets whether to render the container.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | bool | Set to true to render the container element, or false to skip rendering. |
Returns
static: New instance with the updated container value.
containerAttributes()
Section titled “containerAttributes() ”public function containerAttributes(array $attributes): staticSets the container attributes.
Parameters
| Parameter | Type | Description |
|---|---|---|
$attributes | array | Array of attributes to apply to the container element. |
Returns
static: New instance with the updated containerAttributes value.
containerClass()
Section titled “containerClass() ”public function containerClass(string|Stringable|UnitEnum|null $value, bool $override = false): staticAdds a CSS class to the container element attributes.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | string|Stringable|UnitEnum| | CSS class name to add. |
$override | bool | Whether to override existing class value. |
Returns
static: New instance with the updated containerAttributes value.
containerRemoveAttribute()
Section titled “containerRemoveAttribute() ”public function containerRemoveAttribute(string|UnitEnum $key): staticRemoves a specific HTML attribute from the container element.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string|UnitEnum | Attribute name to remove. |
Returns
static: New instance without the specified container attribute.
containerSetAttribute()
Section titled “containerSetAttribute() ”public function containerSetAttribute(string|UnitEnum $key, mixed $value): staticSets a single HTML attribute for the container element.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string|UnitEnum | Attribute name. |
$value | mixed | Attribute value. |
Returns
static: New instance with the updated containerAttributes value.
containerTag()
Section titled “containerTag() ”public function containerTag(false|UnitEnum $value): staticSets the container tag name.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | false|UnitEnum | Tag name for the container element, or false to disable. |
Returns
static: New instance with the updated containerTag value.
getContainerAttribute()
Section titled “getContainerAttribute() ”public function getContainerAttribute(string|UnitEnum $key, mixed $default = null): mixedReturns the value of a single HTML attribute for the container element attributes.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string|UnitEnum | Attribute name. |
$default | mixed | Default value when the attribute is missing. |
Returns
mixed: Attribute value or default.
getContainerAttributes()
Section titled “getContainerAttributes() ”public function getContainerAttributes(): arrayReturns the array of HTML attributes for the container element.
Returns
array: Attributes array assigned to the container element.
getContainerTag()
Section titled “getContainerTag() ”public function getContainerTag(): false|UnitEnumReturns the tag name for the container element.
Returns
false|UnitEnum: Tag name for the container element, or false to disable.
isContainer()
Section titled “isContainer() ”public function isContainer(): boolReturns whether the container element should be rendered.
Returns
bool: true if the container element should be rendered, or false to skip rendering.