Skip to content
caliper ui docs

Pro

Book shelf

A shelf of documents as spines. Width follows the page count, so a dozen fit in a row and scan like a list. Hover or focus tugs a spine up by its top; choosing one takes it off the shelf, its neighbours lean into the gap, and the book swings round beside the shelf to show its cover, page edge and details.

Pro
pnpm dlx shadcn@latest add @caliper/book-shelf

Platform team library

Twelve runbooks, handbooks and reviews, 988 pages in all

Pick a book

12 documents. Hover or focus a spine to tug it; press it to take the book off the shelf.

Last updated by Priya N. on October 14

Installs components/ui/book-shelf.tsxDepends on @radix-ui/react-slot, lucide-reactMotion none in component source

When to use

Use it for

  • A library of runbooks, handbooks or reports where people browse before they open.
  • Showing how much there is and who owns it, with one document inspected at a time.

Skip it when

  • Search results or anything people filter by text; use a list or a table.
  • More than about twenty documents; the shelf scrolls sideways and loses its overview.

Decisions

Why it is built this way, so you know what to keep when you change your copy.

Behaviour

One tab stop, arrows between spines
The shelf is a list of toggle buttons. Left, Right, Home and End move, Enter or Space pulls a book out, Escape puts it back, and each spine is named with title, author and page count.
A taken book leaves its slot
The chosen spine becomes an outline the size of the book, so you can see where it goes back and press it to return it. Its neighbours lean into the gap, and the row never reflows.

Styling

Cloth, not colour coding
Spines use a few muted cloth tones with a rounded sheen and headbands so they read as objects. Tone never carries meaning; the cover writes everything out.
Spine height only separates neighbours
Height varies by a few steps so twelve spines read as separate objects. It never encodes a value; width is the only measure, and the cover writes the numbers out.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/book-shelf

Adds its 5 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.

Usage

Import it from your copy of the source. The example behind the preview comes with the source.

example.tsx
import { BookShelf } from "@/components/ui/book-shelf"

The worked example comes with Pro

The 40-line example behind the preview opens here, ready to copy.

  • 626 Pro parts, blocks and page templates, all with source
  • $149 once, with lifetime updates. No renewal
  • A full refund within 14 days if it is not for you
Checking your licence…

API reference

BookShelf

component
PropTypeDefaultDescription
labelstring"Library shelf"Names the shelf for screen readers.
items *readonly BookShelfItem[]—
selectedstring | null—The id of the book pulled out, or null. Controlled when set.
defaultSelectedstring | nullnull
onSelect((id: string | null) => void)—
onOpen((id: string) => void)—Adds an Open button to the cover.
statusDepthStatus"ready"
messagesDepthMessages—
onRetry(() => void)—
disabledboolean—
classNamestring—

Accessibility

It is built on native elements and keeps aria-label, aria-pressed, aria-hidden and aria-live in step with state. Changes that matter are announced through a live region.

KeyBehaviour
→Moves to the next item or value.
←Moves to the previous item or value.
HomeJumps to the first item or the minimum.
EndJumps to the last item or the maximum.
EscapeCloses or cancels, then returns focus to where it came from.

Motion

It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.

All Surfaces examples