Answer Paper
Answer Paper
Drag the paper’s bottom handle to shorten an answer or restore its detail.
Dependencies
Installation
Add this component with your preferred package manager.
pnpm dlx shadcn@4.21.5 add @cavemio/answer-paperFirst install? Configure @cavemio once
Run npx shadcn@4.21.5 init if shadcn is not set up, then merge this entry into the registries field in your existing components.json. Keep your other settings and registries.
{
"registries": {
"@cavemio": "https://registry.cavemio.dev/r/cavemio-{name}.json"
}
}Usage
The demo reproduces the supplied video’s four prepared answer versions. The component displays caller-provided summaries; it does not generate AI text or make network requests.
import { CavemioAnswerPaper } from "@/components/cavemio-answer-paper";
<CavemioAnswerPaper paperColor="#fffdf8" paperRadius={26} levels={[{ id: "short", label: "Brief", readTime: 1, content: <p>The short answer.</p> }, { id: "full", label: "Full answer", readTime: 10, content: <p>Your complete answer and supporting details go here.</p> }]} />Props
| Prop | Type | Description |
|---|---|---|
| levels | readonly AnswerPaperLevel[] | Required. Answer versions ordered from shortest to longest. |
| level | number | Optional. Controlled index into levels. |
| defaultLevel | number | Optional. Starts with the longest answer when omitted. |
| onLevelChange | (index: number) => void | Optional. Called with the selected answer level index. |
| paperColor | CSSProperties["backgroundColor"] | Optional. Background color of the paper. |
| paperRadius | CSSProperties["borderRadius"] | Optional. Border radius of the paper. |
| textColor | CSSProperties["color"] | Optional. Color of the answer text. |
| handleColor | CSSProperties["color"] | Optional. Color of the drag handle. |
| disabled | boolean | Optional. Disable user interaction. |
| ariaLabel | string | Optional. Accessible name for the component. |
| className | string | Optional. Additional CSS classes for the root element. |
| style | CSSProperties | Optional. Inline styles for the root element. |
Accessibility & motion
The bottom handle is a keyboard-accessible slider. Up/Left shorten, Down/Right expand, Home selects the shortest version, and End restores the full answer. Inactive content is inert and hidden from assistive technology. Reduced motion disables spring and word movement, blur, and scale transitions.
pnpm dlx shadcn@4.21.5 add @cavemio/answer-paper