Skip to content
caliper ui docs

Pro

Card switcher

An app switcher for open pages. Cards fan out in depth by recency: the page you are on is in front and each step back is one page older. Flick a card up to close it, press the front card to open it full size.

Pro
pnpm dlx shadcn@latest add @caliper/card-switcher

Open on Mira's phone

Five pages from this morning, the newest in front

Left and right arrows switch, Enter opens, Delete closes, Escape returns from a page.
5 open · 3 of 5
Installs components/ui/card-switcher.tsxDepends on @radix-ui/react-slot, lucide-reactMotion none in component source

When to use

Use it for

  • Mobile-style multitasking: open documents, tabs or conversations.
  • Reviewing a handful of recent items and dropping the ones you are done with.

Skip it when

  • Long lists; use a list with search.
  • Anything that needs all items visible at once.

Decisions

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

Behaviour

Every gesture has a key and a button
Arrow keys move, Enter opens, Delete closes, Escape returns. Previous, Next and Open are plain buttons and a count reads, for example, 4 open · 2 of 4.
Closing is yours to confirm
The card flicks away, then onClose tells you which page it was. You remove it from pages, and the rest close the gap.

Usage

Empty can offer a way back
Pass onReopen and the empty switcher shows Reopen all.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/card-switcher

Adds its 7 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 { CardSwitcher } from "@/components/ui/card-switcher"

The worked example comes with Pro

The 43-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

CardSwitcher

component
PropTypeDefaultDescription
label *string—Accessible name of the switcher, for example "Open pages".
pages *readonly SwitcherPage[]—
currentstring—The id of the front card. Controlled when set; defaults to the last page.
defaultCurrentstring—
onCurrentChange((id: string) => void)—
onClose((id: string) => void)—Called with a page's id after its card has flicked away. Remove the page from `pages`.
onOpen((id: string) => void)—
onBack(() => void)—Called when the full-size page is dismissed.
onReopen(() => void)—When set, the empty switcher offers a "Reopen all" button that calls it.
statusDepthStatus"ready"
messagesDepthMessages—
onRetry(() => void)—
disabledboolean—
classNamestring—

Accessibility

It exposes group and region semantics, with aria-label, aria-describedby, aria-hidden and aria-live kept in step with state. Changes that matter are announced through a live region.

KeyBehaviour
EscapeCloses or cancels, then returns focus to where it came from.
←Moves to the previous item or value.
→Moves to the next item or value.
DeleteRemoves the next character or the selected item.

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