Skip to content
caliper ui docs

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.

Free
pnpm dlx shadcn@latest add @caliper/bookmark-ribbon

Reading list

Save something for later.

  • The case for fewer settings6 min read
  • How we cut our build time in half9 min read
  • A short history of the scroll bar4 min read
Installs components/ui/bookmark-ribbon.tsxDepends on none beyond ReactMotion honours reduced motion

When 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

terminal
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.

example.tsx
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.

PropTypeDefaultDescription
pressedboolean—
defaultPressedbooleanfalse
onPressedChange((pressed: boolean) => void)—
labelstring"Save"What saving does, e.g. "Save article". The pressed state is carried by `aria-pressed`.

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.

All Surfaces examples