{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "motion-presets",
  "title": "Motion Presets",
  "description": "The motion language: temperament table (calm, lively, playful), springs, durations, easing curves and stagger rules used by every MotionKit component.",
  "dependencies": [
    "motion"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://reactmotionkit.com/r/temperaments.json"
  ],
  "files": [
    {
      "path": "lib/motion.ts",
      "content": "import type { Transition } from \"motion/react\"\n\n/**\n * Motion language of React MotionKit.\n *\n * Every interactive animation has three beats: a short charge (anticipation),\n * the action (a spring with weight) and the settle (a bounce, then rest). The\n * amount of each beat comes from the component's temperament, so one setting\n * changes the character of every component:\n *\n * - `calm`: no bounce, 1.5% squash, 260ms. Fintech, enterprise, dashboards.\n * - `lively`: light bounce, 5% squash, 400ms. The default for components.\n * - `playful`: clear bounce, 11% squash, 540ms. The default of the site and its demos.\n *\n * The numbers live in one table, `motion/temperaments.ts` (the brand's motion tokens,\n * copied as they are). This file turns them into Motion transitions; components\n * read them through the `useMotionKit` hook (`lib/motion-kit.tsx`), which also\n * applies the global time scale and the reduced-motion fallback. Docs: MOTION.md.\n */\n\nimport {\n  DEFAULT_TEMPERAMENT,\n  reducedMotion,\n  type Temperament,\n  temperaments,\n} from \"@/lib/temperaments\"\n\nexport { DEFAULT_TEMPERAMENT, type Temperament, temperaments }\n\nexport const temperamentNames = [\"calm\", \"lively\", \"playful\"] as const satisfies Temperament[]\n\ntype Bezier = readonly [number, number, number, number]\n\n/** A temperament's values in the units Motion uses (seconds, fractions, degrees). */\nexport interface TemperamentValues {\n  /** Perceived duration of the spring, in seconds. */\n  duration: number\n  /** When the spring really comes to rest (0.3% threshold), in seconds. */\n  settle: number\n  /** Spring bounciness, 0 (critically damped) to 1. */\n  bounce: number\n  /** Squash & stretch amount for small elements (fraction of their size). */\n  squash: number\n  /** Length of the charge beat, in seconds; its amount is `squash`. */\n  anticipation: number\n  /** Measured overshoot of the spring (fraction), for keyframed settles. */\n  overshoot: number\n  /** Maximum tilt toward the pointer, in degrees. */\n  tilt: number\n  /** Delay between siblings in a group, in seconds. */\n  stagger: number\n}\n\n/** `temperaments` converted to seconds and fractions. */\nexport function temperamentValues(temperament: Temperament): TemperamentValues {\n  const t = temperaments[temperament]\n  return {\n    duration: t.spring.visualDuration,\n    settle: t.settle / 1000,\n    bounce: t.spring.bounce,\n    squash: t.squash,\n    anticipation: t.anticipation / 1000,\n    overshoot: t.overshoot / 100,\n    tilt: t.tilt,\n    stagger: t.stagger / 1000,\n  }\n}\n\n/**\n * Easing function for a CSS `linear()` curve, so JS tweens follow exactly the\n * sampled spring that CSS transitions use.\n */\nexport function linearEasing(css: string) {\n  const points = (/linear\\(([^)]*)\\)/.exec(css)?.[1] ?? \"0, 1\")\n    .split(\",\")\n    .map((value) => Number.parseFloat(value))\n  const last = points.length - 1\n  return (progress: number) => {\n    if (progress <= 0) return points[0] ?? 0\n    if (progress >= 1) return points[last] ?? 1\n    const position = progress * last\n    const index = Math.floor(position)\n    const from = points[index] ?? 0\n    const to = points[index + 1] ?? from\n    return from + (to - from) * (position - index)\n  }\n}\n\n/** Durations in seconds for UI feedback, independent of temperament. */\nexport const durations = {\n  /** Hover, press and focus feedback. */\n  micro: 0.15,\n  /** The reduced-motion fade that replaces the three beats. */\n  fade: reducedMotion.duration / 1000,\n  /** Elements entering, leaving or changing state. */\n  standard: 0.3,\n  /** The one hero moment of a section. */\n  emphasis: 0.65,\n} as const\n\n/** Named cubic-bezier curves. */\nexport const easings = {\n  /** Fast start, long soft landing. Default for entrances. */\n  outExpo: [0.16, 1, 0.3, 1],\n  /** Gentler entrance for small elements. */\n  outQuart: [0.25, 1, 0.5, 1],\n  /** Symmetric, for elements moving between two resting states. */\n  inOutQuart: [0.76, 0, 0.24, 1],\n  /** Material-style emphasized curve, for large surfaces. */\n  emphasized: [0.2, 0, 0, 1],\n} as const satisfies Record<string, Bezier>\n\n/** Delay steps between siblings, in seconds. */\nexport const stagger = {\n  /** Letters and small tokens. */\n  tight: 0.025,\n  /** Words, list items, cards. */\n  base: 0.06,\n  /** Large blocks and sections. */\n  loose: 0.12,\n} as const\n\n/**\n * Returns a per-child delay that caps the total stagger so long lists\n * don't take forever to appear.\n */\nexport function staggerDelay(index: number, step: number = stagger.base, maxTotal = 0.6) {\n  return Math.min(index * step, maxTotal)\n}\n\nexport interface SpringParams {\n  stiffness: number\n  damping: number\n  mass: number\n}\n\n/**\n * Physical spring for a perceived duration and bounce (the same mapping Motion\n * uses for `visualDuration`). Explicit numbers let GSAP, CSS and charts share\n * exactly the spring Motion runs.\n */\nexport function springParams(duration: number, bounce: number): SpringParams {\n  const root = (2 * Math.PI) / (duration * 1.2)\n  const stiffness = root * root\n  const damping = 2 * Math.min(1, Math.max(0.05, 1 - bounce)) * Math.sqrt(stiffness)\n  return { stiffness, damping, mass: 1 }\n}\n\n/**\n * Slows a spring down by `timeScale` (0.25 = four times slower) without\n * changing its shape: time stretches by 1/s, so stiffness scales by s² and\n * damping by s.\n */\nexport function scaleSpring(spring: SpringParams, timeScale: number): SpringParams {\n  return {\n    stiffness: spring.stiffness * timeScale * timeScale,\n    damping: spring.damping * timeScale,\n    mass: spring.mass,\n  }\n}\n\n/** Where a spring travels from 0 to 1 at time `t` (seconds). */\nexport function springAt({ stiffness, damping, mass }: SpringParams, t: number) {\n  const w0 = Math.sqrt(stiffness / mass)\n  const zeta = damping / (2 * Math.sqrt(stiffness * mass))\n  if (zeta < 1) {\n    const wd = w0 * Math.sqrt(1 - zeta * zeta)\n    return 1 - Math.exp(-zeta * w0 * t) * (Math.cos(wd * t) + ((zeta * w0) / wd) * Math.sin(wd * t))\n  }\n  return 1 - Math.exp(-w0 * t) * (1 + w0 * t)\n}\n\n/**\n * Resolved motion for one temperament, time scale and reduced-motion state.\n * Built by the `useMotionKit` hook; also usable directly outside React.\n */\nexport interface MotionTokens {\n  temperament: Temperament\n  /** 1 = normal speed, 0.25 = slow motion. */\n  timeScale: number\n  /** The user (or the docs) asked for reduced motion: the three beats become a fade. */\n  reduced: boolean\n  /** The temperament's values (squash, anticipation, overshoot, tilt are 0 when reduced). */\n  values: TemperamentValues\n  /** Main spring for user-driven motion (position, layout, drag release). */\n  spring: Transition\n  /**\n   * The calm spring whatever the temperament: tables, long text, forms with\n   * errors, checkout and payments never bounce.\n   */\n  springCalm: Transition\n  /** Quicker spring with the same character for small elements (thumbs, icons, presses). */\n  springSmall: Transition\n  /** Physical parameters of `spring` after the time scale, for GSAP, CSS and charts. */\n  springParams: SpringParams\n  /** Tween that follows the spring's own curve, for choreography (entrances, reveals). */\n  tween: Transition\n  /** Short fade that replaces movement for reduced motion. */\n  fade: Transition\n  /** Scales a duration in seconds by the time scale. */\n  seconds: (value: number) => number\n  /** Per-child delay using the temperament's stagger step. */\n  staggerDelay: (index: number, maxTotal?: number) => number\n}\n\nexport function createMotion(\n  temperament: Temperament = DEFAULT_TEMPERAMENT,\n  timeScale = 1,\n  reduced = false,\n): MotionTokens {\n  const base = temperamentValues(temperament)\n  const scale = timeScale > 0 ? timeScale : 1\n  const seconds = (value: number) => value / scale\n  const fade: Transition = { duration: seconds(durations.fade), ease: \"easeOut\" }\n\n  const values: TemperamentValues = reduced\n    ? { ...base, squash: 0, anticipation: 0, overshoot: 0, tilt: 0 }\n    : base\n\n  // Motion's own spring format: dividing the perceived duration by the time scale\n  // slows it down without changing its shape.\n  const spring = (visualDuration: number, bounce: number): Transition => ({\n    type: \"spring\",\n    visualDuration: seconds(visualDuration),\n    bounce,\n  })\n  const calm = temperaments.calm.spring\n\n  return {\n    temperament,\n    timeScale: scale,\n    reduced,\n    values,\n    spring: reduced ? fade : spring(base.duration, base.bounce),\n    // Small elements (thumbs, icons, presses) move a shorter distance: 70% of the\n    // time keeps their speed in line with the main spring.\n    springSmall: reduced ? fade : spring(base.duration * 0.7, base.bounce),\n    springCalm: reduced ? fade : spring(calm.visualDuration, calm.bounce),\n    springParams: scaleSpring(springParams(base.duration, base.bounce), scale),\n    tween: reduced\n      ? fade\n      : {\n          duration: seconds(base.settle),\n          ease: linearEasing(temperaments[temperament].cssEasing),\n        },\n    fade,\n    seconds,\n    staggerDelay: (index, maxTotal = 0.6) =>\n      reduced ? 0 : seconds(staggerDelay(index, base.stagger, maxTotal)),\n  }\n}\n\n/** Squash & stretch pose: wider and shorter (or the reverse with a negative amount). */\nexport function squash(amount: number) {\n  return { scaleX: 1 + amount, scaleY: 1 - amount }\n}\n\n/** Zero-duration transition, for state that must change without animating. */\nexport const instant = { duration: 0 } as const satisfies Transition\n",
      "type": "registry:lib"
    }
  ],
  "meta": {
    "tier": "free",
    "collection": "interface",
    "needsImage": false,
    "addedAt": "2026-10-12",
    "tags": [
      "motion",
      "springs",
      "easing"
    ],
    "tech": [],
    "presets": [],
    "keyboard": [],
    "heavy": false
  },
  "categories": [
    "internal"
  ],
  "type": "registry:lib"
}