Skip to main content

Split Flap Number

Mechanical departure-board split-flap cells with hinged 3D WAAPI flips, alphanumeric charsets, and optional synthesized Web Audio clack.

SGN 14:25

Customize

SizeMedium
Flip step (ms)65

Installation

npx shadcn@latest add @kinetic/split-flap-number

Usage

Pass a string or number to value. Each cell renders an upper and lower half split across a center hinge and cycles through intermediate flaps in 3D via the Web Animations API until it reaches the target character.

import { SplitFlapNumber } from "@/components/kinetic/ui/split-flap-number";

interface FlightBoardProps {
  readonly code: string;
}

export function FlightBoard({ code }: FlightBoardProps) {
  return <SplitFlapNumber value={code} length={6} size="md" />;
}

Charsets, alignment, and sound

Choose a preset charset ("numeric", "alphanumeric", or "uppercase") or pass a custom character string. Lowercase input automatically matches uppercase glyphs when present in the active charset. Set length, align (defaults to "right" for numbers and "left" for strings), padChar, size ("sm", "md", or "lg"), stepMs (default 65, clamped 30 to 200), and maxSteps (default 8, clamped 1 to 20) to control board layout and pacing.

Enable sound to play a synthesized Web Audio mechanical clack on each flap step, tuned with volume (0 to 1, default 0.18). Audio is generated on the fly with zero external asset requests and throttled when multiple cells flip together.

import { SplitFlapNumber } from "@/components/kinetic/ui/split-flap-number";

interface GateDisplayProps {
  readonly gate: string;
  readonly score: number;
}

export function GateDisplay({ gate, score }: GateDisplayProps) {
  return (
    <div className="flex flex-col gap-3">
      <SplitFlapNumber
        value={gate}
        length={5}
        charset="alphanumeric"
        size="lg"
        sound
        volume={0.2}
      />
      <SplitFlapNumber
        value={score}
        length={4}
        align="right"
        padChar="0"
        charset="numeric"
        size="sm"
      />
    </div>
  );
}

Imperative replay

Attach a SplitFlapNumberHandle ref and call replay() to cycle every cell through the charset back to its current character on demand.

import { useRef } from "react";
import {
  SplitFlapNumber,
  type SplitFlapNumberHandle,
} from "@/components/kinetic/ui/split-flap-number";

interface DeparturesTickerProps {
  readonly label: string;
}

export function DeparturesTicker({ label }: DeparturesTickerProps) {
  const boardRef = useRef<SplitFlapNumberHandle>(null);

  return (
    <div className="space-y-3">
      <SplitFlapNumber ref={boardRef} value={label} length={8} />
      <button type="button" onClick={() => boardRef.current?.replay()}>
        Replay
      </button>
    </div>
  );
}

Motion preferences

stepMs scales with speed and the global Kinetic tempo (data-tempo). Under reduced motion, SplitFlapNumber cancels any active flip immediately, snaps every cell straight to its target character without 3D motion, and invokes onComplete. Visual flap cells stay inside aria-hidden="true" while an .sr-only span exposes aria-label or String(value); enable announceChanges to announce updates politely via role="status".

API Reference

SplitFlapNumber

Split-flap departure board component supporting digits, uppercase letters, fixed cell padding, and optional Web Audio clack.

PropTypeDefaultDescription
valuestring | number-Current numeric or alphanumeric readout.
lengthnumber-Optional fixed cell count for station-board alignment.
align"left" | "right""left"Padding alignment inside fixed cells (defaults to right for numbers).
charset"numeric" | "alphanumeric" | "uppercase" | string"alphanumeric"Character wheel sequence stepped through during flips.
stepMsnumber65Duration of each individual flap flip (clamped 30 to 200ms).
maxStepsnumber8Caps intermediate character flips per update (1 to 20).
soundbooleanfalseEnables synthesized Web Audio mechanical flap clack.
volumenumber0.18Clack output gain (0 to 1).
size"sm" | "md" | "lg""md"Flap tile size preset.