npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@humanspeak/svelte-motion

v0.2.0

Published

A Framer Motion-compatible animation library for Svelte 5 that provides smooth, hardware-accelerated animations. Features include spring physics, custom easing, and fluid transitions. Built on top of the motion library, it offers a simple API for creating

Readme

Svelte Motion — Framer Motion API for Svelte 5

NPM version Build Status Coverage Status License Downloads CodeQL Install size Code Style: Trunk TypeScript Types Maintenance

Svelte Motion brings a Framer Motion-style API to Svelte 5 with motion.<tag> components, gestures, variants, exit animations, layout animation, and utility hooks.

For the latest documentation and examples, visit motion.svelte.page.

Install

npm install @humanspeak/svelte-motion
<script lang="ts">
    import { motion } from '@humanspeak/svelte-motion'
</script>

<motion.button initial={{ opacity: 0 }} animate={{ opacity: 1 }} whileTap={{ scale: 0.97 }}>
    Hello motion
</motion.button>

Framer Motion API Parity

Goal: Framer Motion API parity for Svelte where common React examples can be translated with minimal changes.

| Capability | Status | | --------------------------------------------------------- | ------------------------------- | | initial / animate / transition | Supported | | variants (string keys + inheritance) | Supported | | whileHover / whileTap / whileFocus / whileInView | Supported | | Drag (drag, constraints, momentum, controls, callbacks) | Supported | | AnimatePresence (initial, mode, onExitComplete) | Supported | | Layout (layout, layout="position") | Supported (single-element FLIP) | | Shared layout (layoutId) | Supported | | Pan gesture API (whilePan, onPan*) | Not yet supported | | MotionConfig parity beyond transition | Partial | | reducedMotion, features, transformPagePoint | Not yet supported |

Supported elements

Motion components are generated from canonical HTML/SVG tag lists and exported from src/lib/html/.

  • motion.div, motion.button, motion.svg, motion.path, etc.
  • Most standard tags are included.
  • Excluded by generation: script, style, link, meta, title, head, html, body.

Core components

motion.<tag>

Use motion components the same way you use regular elements, with animation props:

<motion.div
    initial={{ opacity: 0, y: 8 }}
    animate={{ opacity: 1, y: 0 }}
    transition={{ duration: 0.25 }}
/>

MotionConfig

MotionConfig currently supports default transition values for descendants.

<script lang="ts">
    import { MotionConfig, motion } from '@humanspeak/svelte-motion'
</script>

<MotionConfig transition={{ duration: 0.4 }}>
    <motion.div animate={{ scale: 1.05 }} />
</MotionConfig>

AnimatePresence

Exit animations on unmount with support for mode="sync" | "wait" | "popLayout" and onExitComplete.

<script lang="ts">
    import { AnimatePresence, motion } from '@humanspeak/svelte-motion'

    let show = $state(true)
</script>

<AnimatePresence mode="wait" onExitComplete={() => console.log('done')}>
    {#if show}
        <motion.div
            key="card"
            initial={{ opacity: 0, scale: 0.9 }}
            animate={{ opacity: 1, scale: 1 }}
            exit={{ opacity: 0, scale: 0.9, transition: { duration: 0.2 } }}
        />
    {/if}
</AnimatePresence>

<motion.button whileTap={{ scale: 0.97 }} onclick={() => (show = !show)}>Toggle</motion.button>

Notes:

  • Direct children of AnimatePresence require key.
  • Exit transition precedence: base { duration: 0.35 } < merged transition < exit.transition.

Interaction props

whileHover

<motion.button whileHover={{ scale: 1.05, transition: { duration: 0.12 } }} />
  • Uses true-hover gating ((hover: hover) and (pointer: fine)).
  • Supports onHoverStart and onHoverEnd.

whileTap

<motion.button whileTap={{ scale: 0.95 }} />
  • Supports onTapStart, onTap, onTapCancel.
  • Keyboard accessible (Enter/Space).

whileFocus

<motion.button whileFocus={{ scale: 1.05, outline: '2px solid blue' }} />
  • Supports onFocusStart and onFocusEnd.

whileInView

<motion.div
    initial={{ opacity: 0, y: 40 }}
    whileInView={{ opacity: 1, y: 0 }}
    onInViewStart={() => console.log('entered')}
    onInViewEnd={() => console.log('left')}
/>
  • Uses IntersectionObserver.
  • Current implementation uses a fixed threshold behavior (no Framer-style viewport options yet).

Drag

Supported drag props:

  • drag: true | 'x' | 'y'
  • dragConstraints: pixel object or element ref
  • dragElastic, dragMomentum, dragTransition
  • dragDirectionLock, dragPropagation, dragSnapToOrigin
  • dragListener, dragControls
  • whileDrag
  • Callbacks: onDragStart, onDrag, onDragEnd, onDirectionLock, onDragTransitionEnd
<script lang="ts">
    import { createDragControls, motion } from '@humanspeak/svelte-motion'

    const controls = createDragControls()
</script>

<button onpointerdown={(e) => controls.start(e)}>Start drag</button>

<motion.div
    drag="x"
    dragControls={controls}
    dragListener={false}
    dragConstraints={{ left: -120, right: 120 }}
    whileDrag={{ scale: 1.03 }}
/>

Variants

<script lang="ts">
    import { motion, type Variants } from '@humanspeak/svelte-motion'

    let open = $state(false)

    const parent: Variants = {
        open: { opacity: 1 },
        closed: { opacity: 0 }
    }

    const child: Variants = {
        open: { x: 0, opacity: 1 },
        closed: { x: -16, opacity: 0 }
    }
</script>

<motion.ul variants={parent} initial="closed" animate={open ? 'open' : 'closed'}>
    <motion.li variants={child}>Item A</motion.li>
    <motion.li variants={child}>Item B</motion.li>
</motion.ul>
  • String variant keys are resolved from variants.
  • Variant state inherits through context.

Layout animation

Single-element FLIP layout animation:

<motion.div layout />
<motion.div layout="position" />
  • layout: translate + scale.
  • layout="position": translate only.
  • Shared layout (layoutId) is not implemented yet.

Utilities

  • useAnimationFrame
  • useMotionTemplate
  • useSpring
  • useTime
  • useTransform
  • useVelocity
  • styleString
  • stringifyStyleObject (deprecated)
  • createDragControls

The package also re-exports core helpers from motion (for example animate, stagger, transform, easings, and utility functions).

SSR behavior

  • Initial visual state is rendered server-side from initial (or first animate keyframe when initial is empty).
  • initial={false} skips initial enter animation.
  • Hydration path is designed to avoid flicker.

Verification snapshot

Validated against current source and test suite (local run):

  • Unit/component tests: 259 passed
  • E2E tests: 78 passed, 1 skipped

Known gaps vs Framer Motion

  • No shared layout API (layoutId, LayoutGroup).
  • No pan gesture API (whilePan, onPan*).
  • whileInView does not yet expose Framer-style viewport options.
  • MotionConfig currently only provides transition defaults.
  • reducedMotion, features, and transformPagePoint are not implemented.

External dependencies

  • motion
  • motion-dom

License

MIT © Humanspeak, Inc.

Credits

Made with ❤️ by Humanspeak