Skip to content
PHP Ecosystem
Explore

CarouselItem

API reference › Bootstrap 6 › item › CarouselItem

final readonly classyii2\extensions\bootstrap6\item\CarouselItem
Uses traitsItemTrait
Sourcesrc/item/CarouselItem.php

Represents a Carousel slide: a .carousel-item element with its content.

PropertyTypeDescriptionDefined by
$content readonly constructorstring|StringableContent of the slide (not encoded).CarouselItem
$options readonly constructorarray<array-key, mixed>HTML attributes of the .carousel-item element. Default: [].CarouselItem
MethodDescriptionDefined by
fromArray() staticCreates a slide from the array configuration documented in Carousel::$items.CarouselItem
to() staticCreates a slide.CarouselItem
withContent()Returns a copy with the given content.CarouselItem
withOptions()Returns a copy with the given .carousel-item attributes.CarouselItem
public static function fromArray(array<array-key, mixed> $config): self

Creates a slide from the array configuration documented in Carousel::$items.

An options key that is not an array is ignored.

Parameters

ParameterTypeDescription
$configarray<array-key, mixed>Slide configuration.

Returns

self

Throws

public static function to(string|Stringable $content): self

Creates a slide.

Parameters

ParameterTypeDescription
$contentstring|StringableContent of the slide (not encoded).

Returns

self

public function withContent(string|Stringable $content): self

Returns a copy with the given content.

Parameters

ParameterTypeDescription
$contentstring|Stringable

Returns

self

public function withOptions(array<array-key, mixed> $options): self

Returns a copy with the given .carousel-item attributes.

Parameters

ParameterTypeDescription
$optionsarray<array-key, mixed>HTML attributes of the .carousel-item element.

Returns

self