Skip to Content
zjkm-ui
Components

Segmented Progress

Progress split into segments, like stories.

Props
5.0s
<SegmentedProgress count={5} current={current} onComplete={next} />

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/segmented-progress.json
import { 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

PropTypeDefaultDescription
countnumberNumber of segments.
currentnumberThe segment playing, from 0.
durationnumber5Seconds the current segment takes.
pausedbooleanfalseFreezes the current segment.
onComplete() => voidCalled when the current segment fills.
labelstring"Story"Used for the spoken value, e.g. "Story 2 of 5".
classNamestringClasses for the bar.

With reduced motion, the current segment still keeps time, drawn fainter.

On this page