Components
Segmented Progress
Progress split into segments, like stories.
<SegmentedProgress count={5} current={current} onComplete={next} />Installation
npx shadcn@latest add https://ui.zjkm.tech/r/segmented-progress.jsonimport { SegmentedProgress } from "@/components/segmented-progress"Using JavaScript? Set tsx: false in components.json and the CLI converts it.
New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.
Usage
Progress split into segments, like stories: done segments are full and the current one fills over duration. When it's full, onComplete fires so you can move on. Set paused while someone presses and holds.
import { SegmentedProgress } from "@/components/segmented-progress";
export function Stories({ stories }: { stories: Story[] }) {
const [i, setI] = useState(0);
return <SegmentedProgress count={stories.length} current={i} onComplete={() => setI((n) => n + 1)} />;
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
count | number | Number of segments. | |
current | number | The segment playing, from 0. | |
duration | number | 5 | Seconds the current segment takes. |
paused | boolean | false | Freezes the current segment. |
onComplete | () => void | Called when the current segment fills. | |
label | string | "Story" | Used for the spoken value, e.g. "Story 2 of 5". |
className | string | Classes for the bar. |
With reduced motion, the current segment still keeps time, drawn fainter.