Progress
--- import { Progress } from "@/components/starwind/progress"; ---
<div class="w-full max-w-[400px]"> <Progress id="demo-progress" value={50} /> </div>import { Progress } from "@/components/starwind/progress";
export function Example() { return ( <> <div className="w-full max-w-[400px]"> <Progress id="demo-progress" value={50} /> </div> </> );}Installation
pnpx starwind@latest add progressnpx starwind@latest add progressyarn dlx starwind@latest add progressFramework Availability
Astro Available React AvailableProgress is available for Astro and React.
Usage
Variants
---import { Progress } from "@/components/starwind/progress";---
<div class="flex flex-col gap-4 w-full max-w-[400px]" slot="preview"> <Progress id="default" value={60} variant="default" /> <Progress id="primary" value={60} variant="primary" /> <Progress id="secondary" value={60} variant="secondary" /> <Progress id="info" value={60} variant="info" /> <Progress id="success" value={60} variant="success" /> <Progress id="warning" value={60} variant="warning" /> <Progress id="error" value={60} variant="error" /></div>Indeterminate
When you need to show a loading state without a specific value, omit the value prop to create an indeterminate progress bar.
---import { Progress } from "@/components/starwind/progress";---
<Progress id="indeterminate" />Dynamic Updates
The Progress component can be updated dynamically by changing the data-value attribute. This is useful for showing real-time progress like file uploads, form completion, or step-by-step processes.
Interactive Progress Example
---import { Progress } from "@/components/starwind/progress";import { Button } from "@/components/starwind/button";---
<div class="flex w-full max-w-[400px] flex-col gap-4"> <h3 class="text-lg font-medium">Interactive Progress Example</h3>
<div class="space-y-4"> <Progress id="interactive-progress" value={25} class="w-full" />
<Button id="toggle-progress" variant="outline">Toggle Progress (25% ⟷ 75%)</Button> </div></div>
<script> let isHighValue = false;
function setupProgressExample() { const progressElement = document.getElementById("interactive-progress"); const toggleButton = document.getElementById("toggle-progress");
if (!progressElement || !toggleButton) return;
toggleButton.addEventListener("click", () => { isHighValue = !isHighValue; const newValue = isHighValue ? 75 : 25;
progressElement.setAttribute("data-value", String(newValue)); }); }
setupProgressExample(); document.addEventListener("astro:after-swap", setupProgressExample);</script>API Reference
Styled Component API
These props are added or materially changed by the installed Astro styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Follow the Primitive and Runtime links for lower-level behavior props.
Progress
Inherits div attributes. Omits `value`.
Contains the following additional props:
Prop Type Default Toggle details
label string —
- Description
- Provides accessible text for the component.
- Classification
- Wrapper prop
max number 100
- Description
- Sets the maximum accepted value.
- Classification
- Wrapper prop
min number 0
- Description
- Sets the minimum accepted value.
- Classification
- Wrapper prop
value number | null null
- Description
- Controls or identifies the component value.
- Classification
- Wrapper prop
variant "default" | "primary" | "secondary" | "info" | "success" | "warning" | "error" "default"
- Description
- Selects the component's visual variant.
- Classification
- Wrapper prop
Primitive And Runtime API
Use these references when you need the lower-level behavior APIs behind Progress.
Primitive API
Runtime API
- Progress primitive
createProgressfrom@starwind-ui/runtime/progress
Changelog
v2.0.0
- Rebuilt Progress on Starwind Runtime for determinate and indeterminate state.
- See the Progress Primitive for the underlying unstyled anatomy and behavior API.
v1.1.3
- Refactor tailwind variants functions into separate
variants.tsfile
v1.1.1
- Add
starwind:initevent listener to enable initialization of additional Progress loaded after an initial page load, such as when using server islands
v1.1.0
- Add
data-slotattribute to enable global styling updates
v1.0.0
- Initial release with starwind v1.7.0