Components
Bookmark ribbon
A save toggle drawn as a ribbon bookmark. Saving unrolls the ribbon from the top while the whole mark dips and settles; unsaving rolls it back up.
pnpm dlx shadcn@latest add @caliper/bookmark-ribbonWhen to use
Use it for
- Save for later on articles, listings and recipes.
- Any pressed state that deserves a little ceremony.
Skip it when
- Lists of hundreds of rows; the dip is for a deliberate press.
- Actions that are not on and off; use a `Button`.
Decisions
Why it is built this way, so you know what to keep when you change your copy.
Behaviour
- Starts as it is
- A bookmark that is saved at load shows the filled ribbon without animating.
Usage
- Named for the action
- It is a toggle with
aria-pressed; name it for what pressing does, like Save article.
Installation
pnpm dlx shadcn@latest add @caliper/bookmark-ribbon
Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.
Usage
This is the code behind the preview above.
import { type ReactNode } from "react" import { BookmarkRibbon } from "@/components/ui/bookmark-ribbon" function Panel({ title, context, className = "max-w-md", children }: { title: string; context: string; className?: string; children: ReactNode }) { return ( <section className={`grid w-full gap-5 rounded-overlay border border-border bg-background p-6 shadow-resting max-sm:p-4 ${className}`}> <div className="grid gap-1"> <p className="font-medium">{title}</p> <p className="text-sm text-muted-foreground">{context}</p> </div> {children} </section> ); } export function BookmarkRibbonDemo() { const articles = [ ["The case for fewer settings", "6 min read"], ["How we cut our build time in half", "9 min read"], ["A short history of the scroll bar", "4 min read"], ]; return ( <Panel title="Reading list" context="Save something for later."> <ul className="grid divide-y divide-border"> {articles.map(([title, time], index) => ( <li key={title} className="flex items-center justify-between gap-3 py-3 first:pt-0 last:pb-0"> <div className="grid gap-0.5"> <span className="text-sm font-medium">{title}</span> <span className="text-sm text-muted-foreground">{time}</span> </div> <BookmarkRibbon defaultPressed={index === 1} label={`Save ${title}`} /> </li> ))} </ul> </Panel> ); }
API reference
BookmarkRibbon
component
Also accepts the native props of its root element and a ref.
Accessibility
It is built on native elements and keeps aria-pressed, aria-label and aria-hidden in step with state.
No custom key handling; Tab and the native activation keys do the work.
Motion
It checks prefers-reduced-motion itself and settles immediately instead of travelling. Every state is still reachable.
Related
- Like buttonA like, star or save that answers at once. The icon fills with one small pop and a ring, the count rolls one step up or down from where it was, and it stays a real toggle with its count in its name.
- Toggle and toggle groupA button that stays pressed, alone or in a raised group that holds one choice or many and moves with the arrow keys as a single tab stop.
- Bars morphOne icon made of three bars that become one another. A menu turns into a cross, a plus into a minus, an arrow points the other way. The same bars stay on screen, so a toggle reads as one thing changing state.