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.
pnpm dlx shadcn@latest add @caliper/coin-flipWhen 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
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.
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
API reference
CoinFlip
component
Also accepts the native props of its root element and a ref.
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.
Related
- Dice rollDice that tumble and land. Roll and each die spins through several turns, hops and settles face up on its number, one just after another; the total is announced when they have all landed.
- Spin wheelA prize wheel you flick or spin. It keeps the speed you gave it and slows with friction while a flexible pointer ticks against each peg. The prize is drawn by weight before the wheel slows, so the odds are honest however it is spun.
- HourglassA sand timer for a short, fixed time. Sand drains from the top bulb in a thin stream and heaps up in the bottom one, with the time left beneath. Flip turns the glass over and starts again.