Springs
trovecn/springsFreeUtility
Three-tier spring/tween motion tokens — fast, moderate, slow.
Install it
npx shadcn@latest add https://trovecn.dev/r/springs.jsonSource
1import type { Easing, Transition } from "motion/react";23/**4 * Motion tokens. Four tiers, each an enter spring paired with a faster,5 * bounce-free exit tween. Never hand-write a duration/transition inline —6 * import the tier that matches how big the thing moving is, and how often7 * it fires.8 */910/** Strong ease-out, matching this repo's `docs/design-system.md` guidance that built-in11 * easing keywords are too weak for deliberate UI motion. Used on every12 * tier's exit tween. Motion's array form of `cubic-bezier(0.23, 1, 0.32, 1)`.13 * Exported so a component with its own bespoke, non-tier tween (e.g. a14 * checkmark `pathLength` draw) can reuse the same curve instead of a bare15 * easing keyword. */16export const easeOutStrong: Easing = [0.23, 1, 0.32, 1];1718interface SpringTier {19 /** Enter transition — spring, responds naturally to interruption. */20 enter: Transition;21 /** Exit transition — plain tween, one notch quicker, no bounce. */22 exit: Transition;23}2425export const spring = {26 /** Continuous, pointer-tracked motion only: proximity-hover pills, live27 * highlight rects that follow the cursor, drag indicators. Anything28 * triggered by a discrete click/open — even something small — belongs on29 * `quick` or above. Kept at its current speed; this tier is not part of30 * the retune, it already needs to feel instant. */31 fast: {32 enter: { type: "spring", duration: 0.08, bounce: 0 },33 exit: { duration: 0.06, ease: easeOutStrong },34 },35 /** One-shot feedback that isn't continuously tracked: tooltips, preview36 * cards, icon crossfades, small entrance staggers. Enough spring to read37 * as motion rather than a cut, still fast enough to keep up with the38 * interaction that triggered it. */39 quick: {40 enter: { type: "spring", duration: 0.14, bounce: 0.1 },41 exit: { duration: 0.1, ease: easeOutStrong },42 },43 /**44 * Short travel / small expansion (dropdown & tab indicators, switch45 * thumb, accordions) and panels that must land exactly (mobile drawer,46 * selection merge/split).47 */48 moderate: {49 enter: { type: "spring", duration: 0.2, bounce: 0.12 },50 exit: { duration: 0.15, ease: easeOutStrong },51 },52 /** Large surfaces: dialogs, side panels, stepped flows. */53 slow: {54 enter: { type: "spring", duration: 0.32, bounce: 0.18 },55 exit: { duration: 0.22, ease: easeOutStrong },56 },57} satisfies Record<"fast" | "quick" | "moderate" | "slow", SpringTier>;
What it pulls in
npm packages
Files it writes
More from trovecn
All 26 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Font weightfont-weight | trovecn | Utilities | Free | no deps | |
| Utilsutils | trovecn | Utilities | Free | 2 deps |
