Story Viewer
betaA story card whose segmented progress bars fill in turn while the slides crossfade, with tap zones to step through.
- Display
- 1 file
- 1 npm package
- Accessibility notes
Loading the example…
pnpm dlx @dowel-ui/cli add story-viewernpm packages installed: class-variance-authority.
import { StoryViewer } from "@/components/ui/story-viewer";Default
Demo
With Media
<StoryViewer>
| Prop | Type | Default |
|---|---|---|
slides (required) | StorySlide[] | — |
avatarThe avatar beside the caption. Defaults to a dot in the foreground colour. | ReactNode | — |
captionThe caption for slides without their own. | ReactNode | — |
defaultIndexInitial slide index when uncontrolled. | number | 0 |
indexControlled slide index. | number | — |
intervalHow long each slide shows, in milliseconds. | number | 2000 |
labelsNames for the tap zones. | { previous?: string; next?: string } | — |
loopStart again after the last slide. Otherwise it stops there and calls | boolean | true |
onEndCalled when the last slide finishes and | () => void | — |
onIndexChange | (index: number) => void | — |
pausedHold the story on the current slide. | boolean | false |
size | "sm" | "md" | "lg" | "md" |
Plus every attribute of <section> except children, onChange.
The root is a labelled region with aria-roledescription="carousel" (named "Stories" unless you pass aria-label), and each slide is a group named "2 of 3: <label>", with inactive slides aria-hidden. The start and end halves of the media are real buttons ("Previous story", "Next story", renameable through `labels`) with a visible focus ring, and ArrowLeft and ArrowRight step through anywhere in the card, swapped in right-to-left layouts. Hovering the card or moving focus into it pauses the auto-advance, as does `paused`, so nobody has to race the timer; the slide area is a polite live region only while paused, so the user's own steps are announced and the auto-advance is not. Progress bars and placeholder art are aria-hidden. Under reduced motion slides swap without the crossfade.
10/10
checks passed
- Tested — passes
- axe assertion — passes
- Keyboard tested — passes
- Storybook examples — passes
- Accessibility documented — passes
- Semantic tokens only — passes
- Motion from tokens — passes
- className merged — passes
- Visible focus — passes
- No fixed widths — passes