ProgressBar
API reference › Bootstrap 6 › item › ProgressBar
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.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$animated readonly constructor | bool | Whether to animate the stripes (progress-bar-animated). Default: false. | ProgressBar |
$ariaLabel readonly constructor | string| | Accessible name rendered as aria-label, or null to omit it. Default: null. | ProgressBar |
$label readonly constructor | string|Stringable | Content of the .progress-bar element. Default: ''. | ProgressBar |
$options readonly constructor | array<array-key, | HTML attributes of the .progress-bar element. Default: []. | ProgressBar |
$percent readonly constructor | float| | Current value, between the widget min and max. | ProgressBar |
$striped readonly constructor | bool | Whether to render stripes (progress-bar-striped). Default: false. | ProgressBar |
$theme readonly constructor | yii2\| | Theme color rendered as the theme-{value} class, or null for the default. Default: null. | ProgressBar |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
fromArray() static | Creates a bar from the array configuration documented in Progress::$bars. | ProgressBar |
to() static | Creates 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 |
Method details
Section titled “Method details”fromArray()
Section titled “fromArray() ”public static function fromArray(array<array-key, mixed> $config): selfCreates 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
| Parameter | Type | Description |
|---|---|---|
$config | array<array-key, | Bar configuration. |
Returns
self
Throws
yii\base\InvalidConfigException: if the bar has nofloat|intpercent, or itsthemeis astringthat is not aThemevalue.
public static function to(float|int $percent, string|Stringable $label = ''): selfCreates a bar.
Parameters
| Parameter | Type | Description |
|---|---|---|
$percent | float| | Current value, between the widget min and max. |
$label | string|Stringable | Content of the .progress-bar element. |
Returns
self
withAnimated()
Section titled “withAnimated() ”public function withAnimated(bool $animated): selfReturns a copy with the given stripe animation flag.
Parameters
| Parameter | Type | Description |
|---|---|---|
$animated | bool |
Returns
self
withAriaLabel()
Section titled “withAriaLabel() ”public function withAriaLabel(string|null $ariaLabel): selfReturns a copy with the given accessible name.
Parameters
| Parameter | Type | Description |
|---|---|---|
$ariaLabel | string| |
Returns
self
withLabel()
Section titled “withLabel() ”public function withLabel(string|Stringable $label): selfReturns a copy with the given label.
withOptions()
Section titled “withOptions() ”public function withOptions(array<array-key, mixed> $options): selfReturns a copy with the given .progress-bar attributes.
Parameters
| Parameter | Type | Description |
|---|---|---|
$options | array<array-key, | HTML attributes of the .progress-bar element. |
Returns
self
withPercent()
Section titled “withPercent() ”public function withPercent(float|int $percent): selfReturns a copy with the given value.
Parameters
| Parameter | Type | Description |
|---|---|---|
$percent | float| |
Returns
self
withStriped()
Section titled “withStriped() ”public function withStriped(bool $striped): selfReturns a copy with the given stripes flag.
Parameters
| Parameter | Type | Description |
|---|---|---|
$striped | bool |
Returns
self
withTheme()
Section titled “withTheme() ”public function withTheme(yii2\extensions\bootstrap6\enum\Theme|string|null $theme): selfReturns a copy with the given theme color.
Parameters
| Parameter | Type | Description |
|---|---|---|
$theme | yii2\| |
Returns
self
Throws
yii\base\InvalidConfigException: if$themeis astringthat is not aThemevalue.