# StepItem

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

[API reference](/docs/api/index.md) › [Bootstrap 6](/docs/extensions/bootstrap6/reference/index.md) › [item](/docs/extensions/bootstrap6/reference/item/index.md) › StepItem

| final readonly class | `yii2\extensions\bootstrap6\item\StepItem` |
| --- | --- |
| Uses traits | [`ItemTrait`](/docs/extensions/bootstrap6/reference/item/itemtrait/index.md) |
| Source | [`src/item/StepItem.php`](https://github.com/yii2-extensions/bootstrap6/blob/main/src/item/StepItem.php#L20) |

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

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-active"></span>`$active` readonly constructor | `bool` | Whether the step is completed or current (`.active`). Default: `false`. | `StepItem` |
| <span id="property-description"></span>`$description` readonly constructor | `string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php)`\|null` | Secondary text rendered under the label, or `null` for none. Default: `null`. | `StepItem` |
| <span id="property-encode"></span>`$encode` readonly constructor | `bool\|null` | Whether to HTML-encode [`$label`](/docs/extensions/bootstrap6/reference/item/stepitem/index.md#property-label) and [`$description`](/docs/extensions/bootstrap6/reference/item/stepitem/index.md#property-description), or `null` to use `Stepper::$encodeLabels`. Default: `null`. | `StepItem` |
| <span id="property-label"></span>`$label` readonly constructor | `string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php) | Label of the step. | `StepItem` |
| <span id="property-options"></span>`$options` readonly constructor | `array<array-key, mixed>` | HTML attributes of the `.stepper-item` element. Default: `[]`. | `StepItem` |
| <span id="property-theme"></span>`$theme` readonly constructor | [`yii2\extensions\bootstrap6\enum\Theme`](/docs/extensions/bootstrap6/reference/enum/theme/index.md)`\|string\|null` | Theme color rendered as the `theme-{value}` class, or `null` for the default. Default: `null`. | `StepItem` |
| <span id="property-url"></span>`$url` readonly constructor | `array<array-key, mixed>\|string\|null` | URL processed by [`Url::to()`](/docs/api/yii/helpers/baseurl/index.md#method-to), or `null` for a step without link; any step with a URL renders the stepper as links. Default: `null`. | `StepItem` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`fromArray()`](#method-fromArray) static | Creates a step from the array configuration documented in `Stepper::$items`. | `StepItem` |
| [`to()`](#method-to) static | Creates a step. | `StepItem` |
| [`withActive()`](#method-withActive) | Returns a copy with the given active state. | `StepItem` |
| [`withDescription()`](#method-withDescription) | Returns a copy with the given description. | `StepItem` |
| [`withEncode()`](#method-withEncode) | Returns a copy with the given encoding flag. | `StepItem` |
| [`withLabel()`](#method-withLabel) | Returns a copy with the given label. | `StepItem` |
| [`withOptions()`](#method-withOptions) | Returns a copy with the given `.stepper-item` attributes. | `StepItem` |
| [`withTheme()`](#method-withTheme) | Returns a copy with the given theme color. | `StepItem` |
| [`withUrl()`](#method-withUrl) | Returns a copy with the given URL. | `StepItem` |

## Method details

### fromArray() <span id="method-fromArray"></span>

```php
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**

| Parameter | Type | Description |
| --- | --- | --- |
| `$config` | `array<array-key, mixed>` | Step configuration. |

**Returns**

`self`

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): if the step has no `string|Stringable` `label`, or its `theme` is a `string` that is not a [`Theme`](/docs/extensions/bootstrap6/reference/enum/theme/index.md) value.

### to() <span id="method-to"></span>

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

Creates a step.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$label` | `string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php) | Label of the step. |
| `$description` | `string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php)`\|null` | Secondary text rendered under the label, or `null` for none. |

**Returns**

`self`

### withActive() <span id="method-withActive"></span>

```php
public function withActive(bool $active): self
```

Returns a copy with the given active state.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$active` | `bool` |  |

**Returns**

`self`

### withDescription() <span id="method-withDescription"></span>

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

Returns a copy with the given description.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$description` | `string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php)`\|null` |  |

**Returns**

`self`

### withEncode() <span id="method-withEncode"></span>

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

Returns a copy with the given encoding flag.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$encode` | `bool\|null` |  |

**Returns**

`self`

### withLabel() <span id="method-withLabel"></span>

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

Returns a copy with the given label.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$label` | `string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php) |  |

**Returns**

`self`

### withOptions() <span id="method-withOptions"></span>

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

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

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$options` | `array<array-key, mixed>` | HTML attributes of the `.stepper-item` element. |

**Returns**

`self`

### withTheme() <span id="method-withTheme"></span>

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

Returns a copy with the given theme color.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$theme` | [`yii2\extensions\bootstrap6\enum\Theme`](/docs/extensions/bootstrap6/reference/enum/theme/index.md)`\|string\|null` |  |

**Returns**

`self`

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): if `$theme` is a `string` that is not a [`Theme`](/docs/extensions/bootstrap6/reference/enum/theme/index.md) value.

### withUrl() <span id="method-withUrl"></span>

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

Returns a copy with the given URL.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$url` | `array<array-key, mixed>\|string\|null` | URL processed by [`Url::to()`](/docs/api/yii/helpers/baseurl/index.md#method-to). |

**Returns**

`self`