Progress Primitive
Progress is a Starwind Runtime primitive in the static-semantic contract family. Astro and React share one semantic component API. React coordinates reactive state through controlled and default props plus callbacks. Astro renders initial state and coordinates later changes through DOM events and Runtime methods. Raw HTML uses Runtime attributes, DOM events, and imperative methods.
Anatomy
Use the Astro primitive adapter to render Progress anatomy with the Runtime wiring included.
---import { Progress } from "@starwind-ui/astro/progress";---
<Progress.Root> <Progress.Label>Upload progress</Progress.Label> <Progress.Track> <Progress.Indicator /> </Progress.Track> <Progress.Value>Selected value</Progress.Value></Progress.Root>Use the React primitive adapter when Progress state participates in React rendering.
import { Progress } from "@starwind-ui/react/progress";
export function Example() { return ( <Progress.Root> <Progress.Label>Upload progress</Progress.Label> <Progress.Track> <Progress.Indicator /> </Progress.Track> <Progress.Value>Selected value</Progress.Value> </Progress.Root> );}Render the Progress data-sw-* contract yourself, then initialize createProgress.
<div data-sw-progress role="progressbar"> <span data-sw-progress-label role="presentation">Upload progress</span> <div data-sw-progress-track> <div data-sw-progress-indicator></div> </div> <span data-sw-progress-value aria-hidden="true">Selected value</span></div>
<script type="module"> import { createProgress } from "@starwind-ui/runtime/progress";
const root = document.querySelector("[data-sw-progress]"); if (root) { createProgress(root); }</script>API Reference
Root
The main element that owns the Progress Runtime instance.
- Default element
- div
- Discovery hook
- data-sw-progress
- Role
- progressbar
Props
value number | null null
- Description
- Controls the current Progress value.
- Kind
- control
- Targets
- -
- Full type
- number | null
- React
Use value for controlled state.
value
- Astro
Use value for initial state and call setValue for later updates.
valuesetValue
- Runtime / HTML
Use data-value for initial state and call setValue for later updates.
data-valuesetValue
max number 100
- Description
- Configures the max option for the Root part.
- Kind
- option
- Targets
- -
- Full type
- number
min number 0
- Description
- Configures the min option for the Root part.
- Kind
- option
- Targets
- -
- Full type
- number
format Intl.NumberFormatOptions -
- Description
- Configures the format option for the Root part.
- Kind
- option
- Targets
- -
- Full type
- Intl.NumberFormatOptions
getAriaValueText (formattedValue: string | null, value: ProgressValue) => string -
- Description
- Configures the get aria value text option for the Root part.
- Kind
- option
- Targets
- -
- Full type
- (formattedValue: string | null, value: ProgressValue) => string
locale Intl.LocalesArgument -
- Description
- Sets the locale used by Progress.
- Kind
- option
- Targets
- -
- Full type
- Intl.LocalesArgument
State
value ProgressValue value
- Description
- Tracks the current Progress value.
- Initial attribute
- data-value
- Runtime getter
- getValue
- Runtime setter
- setValue
- React
Use value for controlled state.
value
- Astro
Use value for initial state and call setValue for later updates.
valuesetValue
- Runtime / HTML
Use data-value for initial state and call setValue for later updates.
data-valuesetValue
Data Attributes
Runtime hooks
State
Metadata
Track
The track that contains the Progress range.
- Default element
- div
- Discovery hook
- data-sw-progress-track
- Role
- -
Data Attributes
Runtime hooks
Indicator
Visual state indicator rendered by Progress.
- Default element
- div
- Discovery hook
- data-sw-progress-indicator
- Role
- -
Data Attributes
Runtime hooks
Value
Displays the current Progress value.
- Default element
- span
- Discovery hook
- data-sw-progress-value
- Role
- -
Data Attributes
Runtime hooks
Metadata
Label
Text label associated with Progress.
- Default element
- span
- Discovery hook
- data-sw-progress-label
- Role
- -
Data Attributes
Runtime hooks
Runtime API
- Factory
createProgress- Import
@starwind-ui/runtime/progress- Root hook
- root
data-sw-progress - Option props
- format, getAriaValueText, locale, max, min, value
Option Lifecycles
| Option | Lifecycle |
|---|---|
| format | setter-backed |
| getAriaValueText | setter-backed |
| locale | setter-backed |
| max | setter-backed |
| min | setter-backed |
| value | setter-backed |
Runtime Setters
Related Styled Components
Changelog
View version history v1.0.0 3 releases
v1.0.0
- Promoted this Primitive's vendoring version to the stable 1.0.0 baseline. Its existing API and Runtime behavior carry forward from the previous release.
v0.1.1
- Marked generated React Primitive files as client modules so vendored installs preserve client boundaries in React server frameworks.
v0.1.0
- Introduced determinate and indeterminate progress state with accessible value metadata.