Progress
A progress bar on Base UI Progress.
For progress that can be measured. The fill moves to a new value over 300ms, and at once with reduced motion. With value={null} the item draws an empty track, so use @khaeli/spinner or @khaeli/loader when the amount is not known.
Default
import { Progress } from "@/components/ui/progress"
export default function ProgressDefault() {
return <Progress value={64} aria-label="Storage used" className="w-full max-w-xs" />
}
With label and value
Importing tasks
import { Progress, ProgressLabel, ProgressValue } from "@/components/ui/progress"
export default function ProgressWithLabelAndValue() {
return (
<Progress value={38} className="w-full max-w-xs">
<ProgressLabel>Importing tasks</ProgressLabel>
<ProgressValue />
</Progress>
)
}
Changing value
Uploading the release notes
"use client"
import { useState } from "react"
import { Button } from "@/components/ui/button"
import { Progress, ProgressLabel, ProgressValue } from "@/components/ui/progress"
export default function ProgressChangingValue() {
const [value, setValue] = useState(20)
return (
<div className="flex w-full max-w-xs flex-col items-start gap-6">
<Progress value={value}>
<ProgressLabel>Uploading the release notes</ProgressLabel>
<ProgressValue />
</Progress>
<Button variant="outline" onClick={() => setValue(value === 100 ? 0 : value + 20)}>
{value === 100 ? "Start again" : "Upload the next part"}
</Button>
</div>
)
}
Steps of a range
Launch checklist
"use client"
import { Progress, ProgressLabel, ProgressValue } from "@/components/ui/progress"
export default function ProgressStepsOfARange() {
return (
<Progress value={3} max={8} getAriaValueText={(_, value) => `${value} of 8 tasks done`} className="w-full max-w-xs">
<ProgressLabel>Launch checklist</ProgressLabel>
<ProgressValue>{(_, value) => `${value} of 8`}</ProgressValue>
</Progress>
)
}
Installation
npx shadcn@latest add @khaeli/progressbunx --bun shadcn@latest add @khaeli/progressInstall @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.
Installs with
- Registry items
- npm packages
- @base-ui/react ^1.7.0
Accessible name
- The bar is a
progressbarand needs a name:ProgressLabelinside it names it, and without one passaria-label. - The value is read as a percentage of
mintomax(38%). When a percentage is the wrong reading,getAriaValueTextsays it in words (3 of 8 tasks done) and a function as the child ofProgressValuewrites the visible text.
Registry JSON
The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/progress.json