CarouselItem
API reference › Bootstrap 6 › item › CarouselItem
Represents a Carousel slide: a .carousel-item element with its content.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$content readonly constructor | string|Stringable | Content of the slide (not encoded). | CarouselItem |
$options readonly constructor | array<array-key, | HTML attributes of the .carousel-item element. Default: []. | CarouselItem |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
fromArray() static | Creates a slide from the array configuration documented in Carousel::$items. | CarouselItem |
to() static | Creates a slide. | CarouselItem |
withContent() | Returns a copy with the given content. | CarouselItem |
withOptions() | Returns a copy with the given .carousel-item attributes. | CarouselItem |
Method details
Section titled “Method details”fromArray()
Section titled “fromArray() ”public static function fromArray(array<array-key, mixed> $config): selfCreates a slide from the array configuration documented in Carousel::$items.
An options key that is not an array is ignored.
Parameters
| Parameter | Type | Description |
|---|---|---|
$config | array<array-key, | Slide configuration. |
Returns
self
Throws
yii\base\InvalidConfigException: if the slide has nostring|Stringablecontent.
public static function to(string|Stringable $content): selfCreates a slide.
Parameters
| Parameter | Type | Description |
|---|---|---|
$content | string|Stringable | Content of the slide (not encoded). |
Returns
self
withContent()
Section titled “withContent() ”public function withContent(string|Stringable $content): selfReturns a copy with the given content.
withOptions()
Section titled “withOptions() ”public function withOptions(array<array-key, mixed> $options): selfReturns a copy with the given .carousel-item attributes.
Parameters
| Parameter | Type | Description |
|---|---|---|
$options | array<array-key, | HTML attributes of the .carousel-item element. |
Returns
self