Motion Core
boldkit/motion-coreFreeUtility
BoldKit Motion core — framework-agnostic, SSR-safe primitives (observeReveal, staggerChildren, triggerAnimation, startViewTransition, prefersReducedMotion) shared by every motion adapter.
Live preview
live · rendered by the registry
Rendered by boldkit on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://boldkit.dev/r/motion-core.jsonSource
1/**2 * BoldKit Motion Core — framework-agnostic primitives.3 *4 * Consumed by every L3 adapter (React, Vue, future Svelte/Solid/Qwik).5 * Adding a new framework = wrap these functions. No CSS or token changes needed.6 *7 * All functions are SSR-safe: they no-op on the server.8 */910const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';1112// ──────────────────────────────────────────────────────────────────13// Reduced motion detection (cached; updates on media-query change)14// ──────────────────────────────────────────────────────────────────1516let _reducedMotion = false;17let _reducedMotionMql: MediaQueryList | null = null;1819if (isBrowser) {20 _reducedMotionMql = window.matchMedia('(prefers-reduced-motion: reduce)');21 _reducedMotion = _reducedMotionMql.matches;22 _reducedMotionMql.addEventListener('change', (e) => {23 _reducedMotion = e.matches;24 });25}2627export function prefersReducedMotion(): boolean {28 return _reducedMotion;29}3031// ──────────────────────────────────────────────────────────────────32// observeReveal — IntersectionObserver-driven scroll reveal33// ──────────────────────────────────────────────────────────────────3435export type RevealOptions = {36 /** Margin around the root. Negative bottom fires reveal slightly before viewport entry. */37 rootMargin?: string;38 /** Intersection ratio threshold. 0 = any pixel visible. */39 threshold?: number;40 /** If true, unobserves after first reveal. Default true. */41 once?: boolean;42 /** Delay before applying the reveal-in class, in ms. */43 delay?: number;44};4546const DEFAULT_REVEAL_OPTS: Required<RevealOptions> = {47 rootMargin: '0px 0px -10% 0px',48 threshold: 0,49 once: true,50 delay: 0,51};5253/**54 * Observes `el` and toggles `.bk-reveal-in` when it enters the viewport.55 * The element must have the `.bk-reveal` class (and optionally a direction56 * modifier like `.bk-reveal-up`) already applied for the CSS animation to fire.57 *58// … truncated
Files it writes
More from boldkit
All 94 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Chart Exportchart-export | boldkit | Utilities | Free | no deps | |
| Math Curvesmath-curves | boldkit | Utilities | Free | no deps | |
| Utilsutils | boldkit | Utilities | Free | 2 deps |
