Overview
Migrating to styled-static requires understanding its key differences from traditional CSS-in-JS libraries. This guide will help you migrate from popular libraries.Key Differences
Before starting your migration, understand these fundamental differences:No Runtime Interpolation
No Runtime Interpolation
styled-static extracts CSS at build time, so you cannot use runtime props in template literals:
No css Prop
No css Prop
styled-static doesn’t support the
css prop. Use the css helper with className instead:React 19+ Only
React 19+ Only
styled-static uses automatic ref forwarding from React 19. No
forwardRef needed:Vite Only
Vite Only
styled-static uses Vite’s plugin system and cannot work with Webpack or Rollup:
vite.config.ts
Migrating from Emotion
1. Update Dependencies
2. Configure Vite Plugin
vite.config.ts
3. Update Imports
4. Replace css Prop
5. Convert Dynamic Styles
6. Update Global Styles
Migrating from styled-components
1. Update Dependencies
2. Configure Vite Plugin
vite.config.ts
3. Update Imports
4. Convert ThemeProvider
5. Replace attrs with Static Values
6. Replace as Prop
Migrating from Linaria
1. Update Dependencies
2. Update Vite Config
vite.config.ts
3. Update Imports
4. The Syntax is Very Similar!
Most Linaria code works with minimal changes:Common Patterns
Conditional Styling
Dynamic Values
Responsive Styles
Theming
Migration Checklist
Installation
- Removed old CSS-in-JS library
- Installed
@alex.radulescu/styled-static - Configured Vite plugin
Code Updates
- Updated all imports
- Replaced
cssprop withclassName+csshelper - Converted runtime interpolations to variants or CSS variables
- Updated theme provider to CSS variables
- Replaced
asprop withwithComponent - Converted dynamic
attrsto static values
Need Help?
If you encounter issues during migration:Troubleshooting
Common issues and solutions
Comparison
Detailed feature comparison
GitHub Issues
Ask questions or report issues
API Reference
Full API documentation