Skip to main content

Slot Number

Slot-machine reel reveal where digit columns spin rapidly and settle sequentially with configurable spring overshoot, blur, and locale formatting.

7,770

Customize

Spin loops2
Column stagger (ms)140
Overshoot0.45

Installation

npx shadcn@latest add @kinetic/slot-number

Usage

Pass a numeric value to spin all digit columns at high speed before braking each reel sequentially onto its final digit with a spring overshoot.

import { SlotNumber } from "@/components/kinetic/ui/slot-number";

interface JackpotRevealProps {
  readonly amount: number;
}

export function JackpotReveal({ amount }: JackpotRevealProps) {
  return (
    <SlotNumber
      as="p"
      value={amount}
      format={{ style: "currency", currency: "USD", maximumFractionDigits: 0 }}
      className="text-4xl font-semibold tracking-tight"
    />
  );
}

Formatting, stop order, and overshoot

Pass Intl.NumberFormatOptions or a custom (value: number) => string callback to format along with locale (default "en-US"), prefix, and suffix. Non-digit symbols stay anchored in place while every numeric column runs its own reel.

Tune the reveal cadence with stopOrder ("left-to-right" default or "right-to-left"), spinLoops (full 0-to-9 revolutions before braking, default 2, clamped 1 to 5), staggerMs (delay between consecutive reel stops, default 140, clamped 0 to 400), overshoot (0 for damped braking up to 1 for pronounced spring bounce, default 0.45), and blurPx (default 3.2, clamped at 8px max).

import { SlotNumber } from "@/components/kinetic/ui/slot-number";

interface RewardSummaryProps {
  readonly points: number;
}

export function RewardSummary({ points }: RewardSummaryProps) {
  return (
    <SlotNumber
      value={points}
      locale="vi-VN"
      suffix=" pts"
      stopOrder="right-to-left"
      spinLoops={3}
      staggerMs={160}
      overshoot={0.65}
      blurPx={4}
      className="text-3xl font-semibold"
    />
  );
}

Triggers and imperative control

Choose when spinning starts via trigger: "mount" (default), "inView" (fires once when intersecting the viewport), or "manual". Attach a SlotNumberHandle ref to call spin() or reset() (returns reels to zero in idle state) on demand.

import { useRef } from "react";
import {
  SlotNumber,
  type SlotNumberHandle,
} from "@/components/kinetic/ui/slot-number";

interface SpinDemoProps {
  readonly target: number;
}

export function SpinDemo({ target }: SpinDemoProps) {
  const slotRef = useRef<SlotNumberHandle>(null);

  return (
    <div className="space-y-3">
      <SlotNumber
        ref={slotRef}
        value={target}
        trigger="manual"
        className="text-4xl font-semibold"
      />
      <div className="flex gap-2">
        <button type="button" onClick={() => slotRef.current?.spin()}>
          Spin
        </button>
        <button type="button" onClick={() => slotRef.current?.reset()}>
          Reset
        </button>
      </div>
    </div>
  );
}

Motion preferences

Reel cruise duration, staggerMs, spring stepping, and blurPx (max 8px) scale with speed and the global Kinetic tempo. Under reduced motion, SlotNumber skips spinning, snaps every column directly to its target digit without blur, and calls onComplete. Visual reels stay inside aria-hidden="true" while an .sr-only span exposes the formatted text (aria-label overrides it); enable announceChanges to announce updates politely via role="status".

API Reference

SlotNumber

Multi-reel numeric reveal component with staggered column braking and underdamped spring overshoot.

PropTypeDefaultDescription
valuenumber-Target number to reveal.
formatIntl.NumberFormatOptions | ((value: number) => string)-Intl options or custom formatting callback.
localeIntl.LocalesArgument"en-US"Locale for Intl formatting.
spinLoopsnumber2Full reel revolutions before locking (1 to 5).
staggerMsnumber140Delay between consecutive columns braking (0 to 400ms).
stopOrder"left-to-right" | "right-to-left""left-to-right"Sequence in which digit columns settle.
overshootnumber0.45Bounce intensity on settle (0 to 1).
blurPxnumber3.2Peak vertical motion blur while spinning (max 8px).
trigger"mount" | "inView" | "manual""mount"When the initial reveal spin begins.
onComplete() => void-Called once the final reel locks in.