Skip to main content
This guide will walk you through setting up Motion Icons React in your Vite application.

Prerequisites

  • Node.js 14 or higher
  • Vite 3+ or Vite 4+
  • Basic familiarity with Vite and React

Quick Start

Step 1: Create a Vite Project

If you don’t have a Vite project yet, create one:
For TypeScript, use --template react-ts instead of --template react.

Step 2: Install Motion Icons React

Install the required packages:

Step 3: Import CSS

Add the CSS import to your main entry file:
src/main.tsx

Step 4: Use Animated Icons

Now you can use Motion Icons in any component:
src/App.tsx

Step 5: Run Development Server

Start your development server:
Open http://localhost:5173 and you should see your animated icons!

Common Use Cases

Loading States

Notification System

Form Validation

Troubleshooting

Problem: Icons appear but don’t animate.Solution:
  1. Verify you imported the CSS in src/main.tsx:
  2. Clear Vite cache and restart:
  3. Hard refresh your browser (Ctrl+Shift+R or Cmd+Shift+R)
Problem: Cannot find module 'motion-icons-react'Solution:
  1. Ensure the package is installed:
  2. Delete node_modules and reinstall:
  3. Restart your dev server
Problem: Nothing appears where icons should be.Solution:
  1. Check that lucide-react is installed
  2. Verify the icon name is correct (check Lucide icons)
  3. Check browser console for errors
Problem: Errors during npm run buildSolution:
  1. Ensure both packages are in dependencies (not devDependencies)
  2. Clear build cache:
  3. Check that TypeScript types are properly installed

Performance Tips

1. Optimize Bundle Size

Vite automatically tree-shakes unused code, but you can further optimize:

2. Use Animation Triggers Wisely

Reduce continuous animations by using triggers:

3. Lazy Load Heavy Components

For pages with many animated icons:

Next Steps

Animation Types

Explore all available animations

Examples

See more real-world examples

API Reference

Complete props documentation

Accessibility

Learn about accessibility features