Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

svelte-animated-icons

shinokada1.7kMIT0.7.0TypeScript support: included

A collection of animated SVG icons for Svelte with customizable draw transitions, events, and accessibility features. Each icon supports hover/click animations, customizable colors, sizes, and stroke widths.

svelte, svelte5, icons, svg, animated-icons, draw-animation, accessible-icons, icon-library, svg-icons, ui-components, customizable-icons

readme

Svelte Animated Icons

A collection of animated SVG icons for Svelte with customizable draw transitions, events, and accessibility features. Each icon supports hover/click animations, customizable colors, sizes, and stroke widths.

Features

  • 🎨 Customizable colors, sizes, and stroke widths
  • ✨ Animated draw transitions on hover or click
  • ♿ Built-in accessibility features
  • 🎯 TypeScript support
  • 🔄 Configurable animation timing
  • 🎮 Multiple event trigger options

Installation

pnpm i -D svelte-animated-icons

Usage

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

<ArrowDown />

With Custom Properties

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

<ArrowDown
  size={32}
  color="#ff0000"
  strokeWidth={2}
  event="onclick"
  pauseDuration={300}
  transitionParams={{
    duration: 800,
    delay: 0
  }}
/>

Props

Prop Type Default Description
size number 24 Icon size in pixels
color string 'currentColor' Icon color (any valid CSS color)
strokeWidth number 1.5 Width of the icon strokes
event 'onmouseenter' | 'onclick' 'onmouseenter' Event that triggers the animation
pauseDuration number 300 Pause duration between animations (ms)
transitionParams object { duration: 800, delay: 0 } Svelte transition parameters
title object - SVG title for accessibility
desc object - SVG description for accessibility
ariaLabel string - Aria label for the icon

Title and Description Props

<ArrowDown
  title={{
    id: 'ArrowDown-title',
    title: 'ArrowDown Icon'
  }}
  desc={{
    id: 'ArrowDown-desc',
    desc: 'A ArrowDown icon that animates on hover'
  }}
/>

Accessibility

All icons include proper ARIA attributes and support custom titles and descriptions. They are keyboard accessible when used with click events.

Browser Support

Works in all modern browsers that support SVG and CSS animations.

Development

Setup

git clone git@github.com:shinokada/svelte-animated-icons.git
cd svelte-animated-icons
pnpm install

Running Tests

pnpm test:e2e
pnpm test

Building

pnpm build

Contributing

Contributions are welcome! Please read our contributing guidelines before submitting a pull request.

License

MIT License - see the LICENSE file for details.

changelog

svelte-animated-icons

0.7.0

Minor Changes

Changed

  • Refactored component to simplify event handling and improve accessibility
  • Removed separate iconsvg snippet and consolidated SVG rendering
  • Simplified prop interface by removing unnecessary props:

    • Removed role prop (now dynamically set based on event)
    • Removed enableFocusStyles and related focus styling props
    • Removed focusOutlineWidth, focusOutlineColor, focusOutlineOffset, and focusOutlineStyle

Added

  • Introduced isAnimating state to prevent multiple simultaneous animations
  • Added dynamic event handlers using $derived to handle different event types more cleanly
  • Improved logic to prevent animation when event is set to 'none'

Removed

  • Deleted complex focus styling CSS and dynamic focus style calculations
  • Removed the wrapper
    elements for different event types
  • Removed buttonId and associated accessibility attributes
  • Deleted positioning styles on the SVG element

Improvements

  • Simplified component structure
  • More flexible event handling
  • Better state management for animations
  • Reduced code complexity

0.6.2

Patch Changes

  • fix: add enableFocusStyles
  • fix: make the focus outline scale with icon size

0.6.1

Patch Changes

  • fix: .svg-icon to style
  • fix: add a prop, class:className

0.6.0

Minor Changes

  • Replaced the <button> with a
    that has proper ARIA attributes:
    • Added role="button" for interactive versions
    • Added role="img" for non-interactive version
    • Added tabindex="0" to make it focusable
    • Added appropriate aria-label
  • Added keyboard support:
    • Added keyboard event handler for the Enter key
    • Added focus styles in CSS
    • Maintained keyboard accessibility
  • Improved the structure:
    • Removed nested button structure
    • Moved all button-like styles to the icon-wrapper
    • Added focus styles for better accessibility

0.5.2

Patch Changes

  • fix: differences between the button and inner div when hovering
    • Using display: inline-flex on the button ensures it only takes up the exact space of its content
    • Setting line-height: 0 removes any extra vertical space
    • Changing the placeholder to display: flex provides better size control and alignment

0.5.1

Patch Changes

  • style: use display: inline-flex on the button ensures it only takes up the exact space of its content style: set line-height: 0 removes any extra vertical space style: change placeholder to display: flex provides better size control and alignment

0.5.0

Minor Changes

  • feat: use svelte snippet

0.4.0

Minor Changes

  • feat: iconicons

0.3.1

Patch Changes

  • fix: duration, delay

0.3.0

Minor Changes

  • feat: flowbite

0.2.0

Minor Changes

  • feat: heroicons