Flip Clock

Newmotion

Mechanical 3D split-flap clock and dynamic counter built with Framer Motion — real-time clock, countdown, stopwatch, date-time, and counter modes with zero external animation dependencies.

$ pnpm dlx shadcn@latest add @byphongphan/flip-clock
Requires @byphongphan in components.json
interactive
Loading preview...

Live Interactive Stage

The Flip Clock is an authentic mechanical split-flap display built natively with Framer Motion (motion), React 19, and CSS 3D perspective transforms. It replicates physical airport departure boards, retro Solari di Udine clocks, and vintage train timetable displays with realistic flap-fold dynamics, internal lighting gradients, and zero third-party canvas engines.


Installation

Install the required dependencies:

$ pnpm add motion lucide-react
Requires @byphongphan in components.json

Copy and paste the component into your project:

components/flip-clock.tsx

Update the import paths to match your project setup.


Usage

1. Real-time Local Clock

Displays hours, minutes, and seconds synchronized with local system time.

import { FlipClock } from "@/components/flip-clock"
export function ClockExample() { return ( <FlipClock mode="clock" size="md" variant="default" showSeconds={true} showLabels={true} sound={true} /> )}

2. Date & Time with Weekday & Month

Shows Day of week (WED), Day of Month (17), Month (09), Year (2026), alongside hours, minutes, and seconds.

<FlipClock  mode="date-time"  size="md"  variant="default"  showDayOfWeek={true}  showDate={true}  showMonth={true}  showYear={true}  showHours={true}  showMinutes={true}  showSeconds={true}/>

3. Countdown Timer

Counts down towards a specific target timestamp or duration with zero-time callback.

<FlipClock  mode="countdown"  targetDate={new Date("2027-01-01T00:00:00")}  showDays={true}  showHours={true}  showMinutes={true}  showSeconds={true}  onComplete={() => alert("Countdown reached zero!")}/>

4. Stopwatch / Elapsed Time

Counts up with pause, resume, and reset capabilities.

<FlipClock mode="stopwatch" isPaused={false} size="lg" variant="amber" />

5. Dynamic Counter

Flips arbitrary numeric or string values (e.g. live visitor counts, fundraising totals).

<FlipClock  mode="counter"  value={1348}  label="VISITORS"  size="xl"  variant="blueprint"/>

Engineering & Architecture

  • Custom 3D Motion Physics: Powered natively by Framer Motion (motion) and CSS 3D perspective transforms (rotateX, preserve-3d, backface culling) with realistic flap-folding dynamics, subpixel border alignment, and internal gradient shading without heavy third-party canvas engines.
  • SSR & Hydration Resilient: Microtask-deferred initial state calculation and declarative template reconciliation prevent hydration mismatches across static site generation (SSG) in Vite and TanStack Start.
  • Synthesized Web Audio Clicks: Generates procedural mechanical split-flap click sounds via the browser's native Web Audio API oscillator synthesis — requiring zero external audio assets or third-party sound libraries.
  • Container Query Scaling: Supports standard fixed scales (sm, md, lg, xl) and a fluid size="full" mode powered by CSS Container Queries ([container-type:inline-size] and cqw), adapting seamlessly to fill 100% of any parent container.

API Reference

FlipClock

PropTypeDefaultDescription
mode?"clock" | "date-time" | "countdown" | "stopwatch" | "counter""clock"Active operating mode
size?"sm" | "md" | "lg" | "xl" | "full""md"Dimension scale of cards ("full" fluidly fills parent container)
variant?"default" | "blueprint" | "amber" | "outline""default"Color and texture theme
value?string | number—Numerical or string value for "counter" mode
label?string—Text label for "counter" mode
targetDate?Date | string | number—Target deadline for "countdown" mode
durationSeconds?number—Duration in seconds for countdown timer
isPaused?booleanfalsePauses clock, countdown, or stopwatch ticking
format12h?booleanfalse12-hour display format
showAmPm?booleantrueRenders AM/PM indicator in 12h clock mode
showDays?booleantrueRenders Days group (countdown mode)
showDayOfWeek?booleantrueRenders weekday (e.g. MON, TUE) in date-time mode
showDate?booleantrueRenders day of month in date-time mode
showMonth?booleantrueRenders month in date-time mode
showYear?booleantrueRenders year in date-time mode
showHours?booleantrueRenders hours unit
showMinutes?booleantrueRenders minutes unit
showSeconds?booleantrueRenders seconds unit
showLabels?booleantrueRenders unit labels beneath cards
showSeparators?booleantrueRenders separators (:, /, etc.)
separator?string":"Custom separator character
sound?booleanfalsePlays procedural mechanical split-flap click sound on update
onComplete?() => void—Callback fired when countdown timer reaches zero
className?string—Additional Tailwind CSS classes

Command Palette

Quick search and commands navigation