Skip to content
PHP Ecosystem
Explore

StepItem

API reference › Bootstrap 6 › item › StepItem

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

Represents a Stepper step: a list item, a <div>, or a link when it has a URL.

PropertyTypeDescriptionDefined by
$active readonly constructorboolWhether the step is completed or current (.active). Default: false.StepItem
$description readonly constructorstring|Stringable|nullSecondary text rendered under the label, or null for none. Default: null.StepItem
$encode readonly constructorbool|nullWhether to HTML-encode $label and $description, or null to use Stepper::$encodeLabels. Default: null.StepItem
$label readonly constructorstring|StringableLabel of the step.StepItem
$options readonly constructorarray<array-key, mixed>HTML attributes of the .stepper-item element. Default: [].StepItem
$theme readonly constructoryii2\extensions\bootstrap6\enum\Theme|string|nullTheme color rendered as the theme-{value} class, or null for the default. Default: null.StepItem
$url readonly constructorarray<array-key, mixed>|string|nullURL processed by Url::to(), or null for a step without link; any step with a URL renders the stepper as links. Default: null.StepItem
MethodDescriptionDefined by
fromArray() staticCreates a step from the array configuration documented in Stepper::$items.StepItem
to() staticCreates a step.StepItem
withActive()Returns a copy with the given active state.StepItem
withDescription()Returns a copy with the given description.StepItem
withEncode()Returns a copy with the given encoding flag.StepItem
withLabel()Returns a copy with the given label.StepItem
withOptions()Returns a copy with the given .stepper-item attributes.StepItem
withTheme()Returns a copy with the given theme color.StepItem
withUrl()Returns a copy with the given URL.StepItem
public static function fromArray(array<array-key, mixed> $config): self

Creates a step from the array configuration documented in Stepper::$items.

Only true activates the step and only a bool encode is used; a description, theme, url, or options of another type is ignored.

Parameters

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

Returns

self

Throws

public static function to(string|Stringable $label, string|Stringable|null $description = null): self

Creates a step.

Parameters

ParameterTypeDescription
$labelstring|StringableLabel of the step.
$descriptionstring|Stringable|nullSecondary text rendered under the label, or null for none.

Returns

self

public function withActive(bool $active): self

Returns a copy with the given active state.

Parameters

ParameterTypeDescription
$activebool

Returns

self

public function withDescription(string|Stringable|null $description): self

Returns a copy with the given description.

Parameters

ParameterTypeDescription
$descriptionstring|Stringable|null

Returns

self

public function withEncode(bool|null $encode): self

Returns a copy with the given encoding flag.

Parameters

ParameterTypeDescription
$encodebool|null

Returns

self

public function withLabel(string|Stringable $label): self

Returns a copy with the given label.

Parameters

ParameterTypeDescription
$labelstring|Stringable

Returns

self

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

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

Parameters

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

Returns

self

public function withTheme(yii2\extensions\bootstrap6\enum\Theme|string|null $theme): self

Returns a copy with the given theme color.

Parameters

ParameterTypeDescription
$themeyii2\extensions\bootstrap6\enum\Theme|string|null

Returns

self

Throws

public function withUrl(array<array-key, mixed>|string|null $url): self

Returns a copy with the given URL.

Parameters

ParameterTypeDescription
$urlarray<array-key, mixed>|string|nullURL processed by Url::to().

Returns

self