Overview
There are two primary methods to install Svelte 5 animation components: using the CLI (recommended) or manual copy-paste. Both methods work with the component registry system.CLI Installation (Recommended)
The fastest way to add components is using theshadcn-svelte CLI, which automatically handles dependencies and setup.
Prerequisites
First, ensure you have a Svelte 5 project set up with the required dependencies:Install a Component
Use the CLI to add any component from the registry:What Gets Installed
The CLI automatically:- Downloads the component files to your project
- Installs required npm dependencies
- Adds necessary CSS variables to your config
- Sets up animation keyframes
- Places files in the correct directory structure
Components are installed to
src/lib/components/magic/ by default.Manual Installation
For more control, you can manually copy component code into your project.Step 1: Create Directory Structure
Create a directory for the component:Step 2: Copy Component Files
Copy the component Svelte file and index file from the registry or documentation. For simple components like Shine Border:Step 3: Install Dependencies
Check the registry entry for required dependencies and install them:registry.json
Step 4: Add CSS Variables
Some components require CSS variables and keyframes. Add these to your Tailwind configuration. For Shine Border, add totailwind.config.js:
tailwind.config.js
Step 5: Copy Type Definitions
For complex components with separate type files, copy those too:src/lib/components/magic/animated-beam/types.ts
Understanding the Registry
The component registry (registry.json) defines all available components and their metadata.
Registry Entry Structure
Each component has an entry like this:Key Fields
- name - Unique identifier for the component
- files - Array of component files to install
- dependencies - npm packages required
- registryDependencies - Other components from the registry this depends on
- cssVars - Tailwind animation configuration
- css - Keyframe definitions
Registry URL Pattern
Components follow this URL structure for registry access:- Border Beam:
https://sv5-animations.vercel.app/registry/border-beam.json - Shine Border:
https://sv5-animations.vercel.app/registry/shine-border.json
Common Dependencies
These packages are commonly used across components:Core Animation Libraries
- motion-sv (v0.1.10+) - Svelte 5 motion library for animations
- runed (v0.37.1+) - Svelte 5 runes utilities
UI Libraries
- @lucide/svelte - Icon library (for interactive components)
- bits-ui - Headless UI components (for buttons)
Specialized Libraries
- svg-dotted-map - For the Dotted Map component
- tailwind-variants - For component variants (Rainbow Button)
CSS Variables Setup
Many components require CSS custom properties for animations.Via Tailwind Config
Add totailwind.config.js:
Utilities Setup
Components require thecn() utility function for class merging:
src/lib/utils.ts
Next Steps
Component Structure
Understand how components are organized
Customization
Learn how to customize components