Skip to content
caliper ui docs

Pro

Coin flip

A coin for settling small things. Press it and it leaps, tumbles end over end and lands with a small bounce while its shadow shrinks and returns beneath it.

Pro
pnpm dlx shadcn@latest add @caliper/coin-flip

Who pays?

Press the coin.

Press the coin

Heads 0 · Tails 0

Installs components/ui/coin-flip.tsxDepends on none beyond ReactMotion honours reduced motion

When to use

Use it for

  • Decision helpers, games and playful empty states.
  • Choosing who goes first.

Skip it when

  • Anything with stakes; it is visual randomness, not a fair-play service.
  • Results that must be repeatable.

Decisions

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

Behaviour

The side is chosen first
A random side is drawn with the browser's random numbers and the tumble is steered to land on it, so the animation never decides the result.

Styling

A coin with an edge
Stacked rim layers give the coin thickness, so the edge shows as it turns.

Usage

Announced
The result is read as a status; Enter and Space flip the coin.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/coin-flip

Adds its 2 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 { CoinFlip } from "@/components/ui/coin-flip"

The worked example comes with Pro

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

CoinFlip

component

Also accepts the native props of its root element and a ref.

PropTypeDefaultDescription
faces[ReactNode, ReactNode]["H", "T"]What each face shows.
names[string, string]["Heads", "Tails"]The side names, read aloud with the result.
onFlip((side: CoinSide) => void)—
durationnumber1500Flight time in milliseconds.

Accessibility

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

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