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

animated-svelte

v0.0.0

Published

A motion-like CSS animation library for Svelte.

Readme

animated-svelte

A motion-like CSS animation library for Svelte 5, providing declarative animations with a simple and intuitive API. This all happens using the in and out directives provided by Svelte.

[!WARNING] This strictly an internal package for now and not intended for public use eventually I may get around the making this public.

pnpm add animated-svelte

Quick Start

pnpm add animated-svelte

[!WARNING] The rest of this documentation was written by AI and my not be completely accurate.

<script>
	import { animated } from 'animated-svelte';
</script>

<animated.div
	initial={{ opacity: 0, scale: 0 }}
	animate={{ opacity: 1, scale: 1 }}
	transition={{ duration: 300 }}
>
	Hello, animated-svelte!
</animated.div>

Components

animated.div and animated.span

Animated versions of standard HTML elements with motion capabilities.

Props

| Prop | Type | Description | | ------------ | ----------------------------------- | ----------------------------------------- | | initial | Partial<AnimationConfig> \| false | Initial animation state (before entering) | | animate | Partial<AnimationConfig> | Target animation state | | exit | Partial<AnimationConfig> | Exit animation state (when leaving) | | transition | Partial<TransitionConfig> | Transition configuration | | ref | HTMLElement \| null | Reference to the DOM element |

Animation Properties

The AnimationConfig type supports the following properties:

  • opacity - number (0-1)
  • scale - number
  • rotate - number (degrees)
  • x - number \| string (px or percentage)
  • y - number \| string (px or percentage)
  • width - number \| string (px or percentage)
  • height - number \| string (px or percentage)
  • filter - string (CSS filter value)

Transition Configuration

type TransitionConfig = {
	duration: number | `${number}s` | `${number}ms`; // Default: 0
	timingFunction: 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out'; // Default: 'ease-out'
	delay: number | `${number}s` | `${number}ms`; // Default: 0
};

Examples

Basic Animation

<animated.div animate={{ rotate: 90 }} transition={{ duration: 0.5, timingFunction: 'ease-out' }}>
	Rotating element
</animated.div>

Enter/Exit Animations

<script>
	import { animated } from 'animated-svelte';

	let isVisible = $state(false);
</script>

<button onclick={() => (isVisible = !isVisible)}> Toggle </button>

{#if isVisible}
	<animated.div
		initial={{ opacity: 0, scale: 0 }}
		animate={{ opacity: 1, scale: 1 }}
		exit={{ opacity: 0, scale: 0 }}
		transition={{ duration: 0.2 }}
	>
		Fade in and scale up
	</animated.div>
{/if}

Position Animation

<animated.div initial={{ x: 0 }} animate={{ x: 100 }} transition={{ duration: 0.5 }}>
	Moving element
</animated.div>

Stagger Animation

{#each Array.from({ length: 5 }) as _, i (i)}
	<animated.div
		initial={{ opacity: 0, y: 20 }}
		animate={{ opacity: 1, y: 0 }}
		transition={{
			duration: 0.3,
			delay: i * 0.1
		}}
	>
		Item {i + 1}
	</animated.div>
{/each}

Resize Animation

<animated.div
	initial={{ width: 50, height: 50 }}
	animate={{ width: 100, height: 100 }}
	transition={{ duration: 0.5 }}
>
	Resizing element
</animated.div>

Combined Animations

<animated.div
	initial={{ rotate: 90, opacity: 0, scale: 0 }}
	animate={{ rotate: 0, opacity: 1, scale: 1 }}
	transition={{ duration: 0.5, timingFunction: 'ease-out' }}
>
	Multiple properties animated together
</animated.div>

Advanced Usage

Using the useAnimation Hook

For custom components or more control, you can use the useAnimation hook directly:

<script>
	import { useAnimation } from 'animated-svelte';

	let elementRef = $state(null);

	const { enter, exit } = useAnimation({
		ref: () => elementRef,
		initial: () => ({ opacity: 0 }),
		animate: () => ({ opacity: 1 }),
		exit: () => ({ opacity: 0 }),
		transition: () => ({ duration: 0.3 })
	});
</script>

<div bind:this={elementRef} in:enter out:exit>Custom animated element</div>