What is styled-static?
Styled-static is a near-zero-runtime CSS-in-JS library for React 19+ that extracts all CSS at build time. Write styled-components syntax you already know, but get the performance of static CSS. What’s “zero”? CSS generation happens at build time (the expensive part). A minimal runtime (~45 bytes) handles className merging. Components are generated inline at build time.Installation
Get started with styled-static in your React 19+ project
Quick Start
Build your first styled component in minutes
Core API
Explore the styled-components API you already know
How It Works
Understand the build-time transformation
Key Features
Static CSS
All CSS extracted at build time, no runtime stylesheet generation
Type-Safe
Full TypeScript support with proper prop inference
Familiar API
styled-components syntax you already know
Tiny Runtime
Minimal ~45 byte runtime for className merging only
Zero Dependencies
Uses native CSS features and Vite’s built-in tools
Inline Components
Components generated at build time, no runtime factories
Quick Example
Here’s a taste of what styled-static looks like:React 19+ Required — styled-static uses automatic ref forwarding, eliminating the need for
forwardRef.Why styled-static?
CSS evolved
CSS evolved
Native nesting, CSS variables, container queries—the gap between CSS and CSS-in-JS is smaller than ever. Modern browsers support everything we need.
CSS-in-JS fatigue
CSS-in-JS fatigue
Most CSS-in-JS libraries are obsolete, complex, or have large runtime overhead. We need something simpler and faster.
Syntactic sugar over CSS modules
Syntactic sugar over CSS modules
Better DX for writing CSS without runtime interpolation. Get the benefits of scoped CSS with a familiar API.
Zero dependencies
Zero dependencies
Minimal attack surface. Nothing to audit. Uses only native CSS features and Vite’s built-in tools.
Intentionally simple
Intentionally simple
95% native browser features + 5% build-time magic. No complex runtime, no CSS parsing overhead.
What We Don’t Do
Styled-static makes intentional trade-offs to stay simple and fast:React 19+ only — Uses automatic ref forwarding (no
forwardRef needed).Vite only — Uses Vite’s AST parser and virtual modules. No Webpack/Rollup support.
Core APIs at a Glance
Styled-static provides 10 core functions:Performance
Styled-static is designed for maximum performance:| Module | Minified | Brotli |
|---|---|---|
| runtime/index.js | 45 B | 50 B |
Next Steps
Install styled-static
Add styled-static to your project with npm, yarn, or bun
Follow the quickstart
Build your first styled component in 5 minutes
Read the API docs
Explore all available APIs and features
See comparisons
Compare styled-static with other CSS-in-JS libraries