Skip to content
PHP Ecosystem
Explore

ProgressBar

API reference › Bootstrap 6 › item › ProgressBar

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

Represents a Progress bar: the single bar, or a segment of a stacked bar.

The range of $percent depends on the widget min and max, so the widget validates it when rendering.

PropertyTypeDescriptionDefined by
$animated readonly constructorboolWhether to animate the stripes (progress-bar-animated). Default: false.ProgressBar
$ariaLabel readonly constructorstring|nullAccessible name rendered as aria-label, or null to omit it. Default: null.ProgressBar
$label readonly constructorstring|StringableContent of the .progress-bar element. Default: ''.ProgressBar
$options readonly constructorarray<array-key, mixed>HTML attributes of the .progress-bar element. Default: [].ProgressBar
$percent readonly constructorfloat|intCurrent value, between the widget min and max.ProgressBar
$striped readonly constructorboolWhether to render stripes (progress-bar-striped). Default: false.ProgressBar
$theme readonly constructoryii2\extensions\bootstrap6\enum\Theme|string|nullTheme color rendered as the theme-{value} class, or null for the default. Default: null.ProgressBar
MethodDescriptionDefined by
fromArray() staticCreates a bar from the array configuration documented in Progress::$bars.ProgressBar
to() staticCreates a bar.ProgressBar
withAnimated()Returns a copy with the given stripe animation flag.ProgressBar
withAriaLabel()Returns a copy with the given accessible name.ProgressBar
withLabel()Returns a copy with the given label.ProgressBar
withOptions()Returns a copy with the given .progress-bar attributes.ProgressBar
withPercent()Returns a copy with the given value.ProgressBar
withStriped()Returns a copy with the given stripes flag.ProgressBar
withTheme()Returns a copy with the given theme color.ProgressBar
public static function fromArray(array<array-key, mixed> $config): self

Creates a bar from the array configuration documented in Progress::$bars.

Only true enables striped and animated; a label, theme, ariaLabel, or options of another type is ignored.

Parameters

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

Returns

self

Throws

public static function to(float|int $percent, string|Stringable $label = ''): self

Creates a bar.

Parameters

ParameterTypeDescription
$percentfloat|intCurrent value, between the widget min and max.
$labelstring|StringableContent of the .progress-bar element.

Returns

self

public function withAnimated(bool $animated): self

Returns a copy with the given stripe animation flag.

Parameters

ParameterTypeDescription
$animatedbool

Returns

self

public function withAriaLabel(string|null $ariaLabel): self

Returns a copy with the given accessible name.

Parameters

ParameterTypeDescription
$ariaLabelstring|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 .progress-bar attributes.

Parameters

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

Returns

self

public function withPercent(float|int $percent): self

Returns a copy with the given value.

Parameters

ParameterTypeDescription
$percentfloat|int

Returns

self

public function withStriped(bool $striped): self

Returns a copy with the given stripes flag.

Parameters

ParameterTypeDescription
$stripedbool

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