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:--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:http://localhost:5173
and you should see your animated icons!
Common Use Cases
Loading States
Notification System
Form Validation
Troubleshooting
Animations not working
Animations not working
Problem: Icons appear but don’t animate.Solution:
- Verify you imported the CSS in
src/main.tsx
: - Clear Vite cache and restart:
- Hard refresh your browser (Ctrl+Shift+R or Cmd+Shift+R)
Module not found error
Module not found error
Problem:
Cannot find module 'motion-icons-react'
Solution:- Ensure the package is installed:
- Delete node_modules and reinstall:
- Restart your dev server
Icons not displaying
Icons not displaying
Problem: Nothing appears where icons should be.Solution:
- Check that lucide-react is installed
- Verify the icon name is correct (check Lucide icons)
- Check browser console for errors
Build errors
Build errors
Problem: Errors during
npm run build
Solution:- Ensure both packages are in dependencies (not devDependencies)
- Clear build cache:
- Check that TypeScript types are properly installed