Response versions
Step between regenerated answers with "2 / 3", and regenerate without losing the old ones.
Used forAI chat appsWriting assistantsMarketing copy toolsSupport reply drafting
Part of AI chat components for React, the parts of a chat in the order they appear.
Install with the shadcn CLI
Registered the namespace? Then it’s shadcn add @hairline/response-versions. Set it up
Templates
Need the whole page?
63 Next.js landing pages, each designed from scratch. Try any of them live; one is $39, all of them $159, and 8 are free.
Where it’s used
AI chat apps
Regenerate an answer and flip between the versions.
Writing assistants
Try a draft again without losing the one you started with.
Marketing copy tools
Compare several versions of a headline or a description.
Support reply drafting
Regenerate a suggested reply and keep the earlier ones.
What it handles for you
Regenerating should not throw away an answer someone half liked. This keeps every version and lets people step back and forth between them.
Step between versions
Arrows move between answers, and “2 / 3” rolls with each step.
The old answer leaves the way you went
It slides out one way through a blur while the next arrives from the other side, and the height eases between them.
Regenerate without losing anything
Regenerate blurs into a spinner while the new version is written, and the count rolls up when it lands.
It wraps any content
Text, code blocks, images or anything else you render as the answer.
Safe at the ends
The arrows are disabled at either end. With one version, only Regenerate is live.
Announced politely
Screen readers hear “Version 2 / 3” as you step.
Overview
Regenerating shouldn’t throw away an answer you half liked. Wrap the answer and this adds a small pager under it. Each step sends the answer you leave out one way through a blur while the next comes in from the other side, the height eases between them and "2 / 3" rolls. Regenerate blurs into a spinner while the new version is written, and the count rolls up when it lands.
States
- single
- One version: the arrows are disabled and only Regenerate is live.
- browsing
- The old answer leaves 24px toward where you came from (260ms) as the new one arrives from the side you stepped toward (420ms); the height eases between them and the counter rolls.
- regenerating
- The arrow blurs into a spinner and Regenerate is disabled until the new version arrives; then "3 / 3" rolls up.
Usage
Depends on lucide-react, installed for you by the CLI along with the keyframes it needs.
Works with
With the AI SDK
Map the Vercel AI SDK’s message parts and chat status onto the component’s props.
Props
- count / index
- number
- How many versions, and which one is shown (zero-based).
- onIndexChange
- (index: number) => void
- Called by the arrows.
- onRegenerate / regenerating
- () => void / boolean
- Shows Regenerate, and a spinner while a version is written.
- children
- ReactNode
- The content of the version shown.
Accessibility and motion
- The counter is announced politely as "Version 2 / 3".
- Arrows are real disabled buttons at either end, so they’re skipped by Tab.
- Installs Number roll. With reduced motion the content simply swaps and the counter changes in place.
Requirements
React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.
The CLI also installs Number roll.
Source
Registry item: /r/response-versions.json


