Skip to main content

Primitives

The foundation every component builds on: motion tokens, the provider and a few small hooks.

Motion tokens

Springs are named by role instead of by numbers, so the same kind of movement feels the same everywhere. Durations, easing curves, scales and blur amounts follow the same idea.

Install

npx shadcn@latest add @kinetic/motion-tokens
RoleStiffness / damping / massUsed for
press520 / 34 / 0.8Button and tile press feedback
pop420 / 26 / 0.85Badges, popovers and tooltips appearing
selection460 / 36 / 0.9Tab indicators and selected state
dialog340 / 30 / 1Dialogs, sheets and drawers
gentle180 / 24 / 1.05Large layout moves
snappy600 / 38 / 0.75Switches, checkboxes and small toggles
bouncy380 / 18 / 0.9Playful emphasis, used sparingly

KineticProvider

The provider holds three settings for everything below it. Each one can be controlled (tempo, accentPreset, reducedMotion) or left to an initial value (defaultTempo, defaultAccentPreset, defaultReducedMotion).

  • tempo multiplies every duration and scales springs while keeping their damping ratio, so a faster tempo never gets bouncier. It is clamped between 0.1 and 10.
  • accentPreset is one of monochrome, emerald, indigo, amber or rose.
  • reducedMotion is "user" (follow the device), "always", "never" or a boolean.
app/layout.tsx
<KineticProvider
  defaultTempo={1}
  defaultAccentPreset="indigo"
  defaultReducedMotion="user"
>
  {children}
</KineticProvider>

Using springs

Read a spring with getSpring(role) from useKinetic(). The transition it returns already follows the current tempo and reduced-motion setting.

components/badge.tsx
"use client";

import { motion } from "motion/react";
import { useKinetic } from "@/components/kinetic/kinetic-provider";

interface BadgeProps {
  readonly children: React.ReactNode;
}

export function Badge({ children }: BadgeProps) {
  const { getSpring } = useKinetic();

  return (
    <motion.span
      initial={{ opacity: 0, scale: 0.94 }}
      animate={{ opacity: 1, scale: 1 }}
      transition={getSpring("pop")}
      className="rounded-full bg-primary px-3 py-1 text-xs text-primary-foreground"
    >
      {children}
    </motion.span>
  );
}

Hooks

HookWhat it does
useReducedMotionSafeReads reduced-motion and fine-pointer media queries without hydration mismatches.
usePointerPositionTracks pointer position and velocity as motion values, with no re-renders.
useThemeObserverReports the resolved light or dark theme and the active accent preset.
useMagneticAdds a spring-damped magnetic pull, only on fine pointers and with motion allowed.

Install a hook by its kebab-case name, for example use-magnetic. It is written to hooks/.

Install

npx shadcn@latest add @kinetic/use-magnetic