Overview
Svelte 5 Animations components follow a consistent structure that makes them easy to understand, maintain, and customize. Each component is organized in a modular way with clear separation of concerns.Directory Organization
All animation components are located insrc/lib/components/magic-ui/ with each component in its own directory:
Component File Structure
Simple Components
Most components have a minimal structure with two files:Complex Components
More complex components include additional files for types and utilities:Props Pattern
TypeScript Interface
Components define their props using TypeScript interfaces that often extend standard HTML attributes:Svelte 5 Props
The new Svelte 5$props() rune is used with destructuring and default values:
Common Props
Most animation components share these common props:class- Custom CSS classes (renamed toclassNameinternally)duration- Animation duration in secondsdelay- Animation delay in secondsstyle- Custom inline styles...restProps- All other HTML attributes
Derived State with Runes
Components use Svelte 5’s$derived and $derived.by runes for reactive computed values:
Utility Integration
All components use thecn() utility function from $lib/utils to merge Tailwind CSS classes:
Animation Libraries
Components use these core animation libraries:- motion-sv - Svelte port of Framer Motion for declarative animations
- runed - Svelte 5 runes utilities
- Tailwind CSS animations - Via
tw-animate-csspackage
Multi-File Components
Some complex components likefile-tree and terminal consist of multiple Svelte files:
Registry Configuration
Every component is defined inregistry.json with metadata:
Next Steps
Installation Methods
Learn how to install and add components to your project
Customization
Discover how to customize components for your needs