@linaria/core

v7.0.0 MIT

Blazing fast zero-runtime CSS in JS library

Weekly Downloads
361.2K
Stars
12.3K
Forks
412
Open Issues
145
Gzip Size
358 B
Unpacked Size
24.6 kB
Dependencies
1
Last Updated
2mo ago

@linaria/core Download Trends

Download trends for @linaria/core0509.0K1.0M1.5M2.0MMar 2025JunSepDecMarApr 2026
@linaria/core

About @linaria/core

Linaria is a zero-runtime CSS-in-JS library designed to inject styles directly into the DOM at a granular level, eliminating the need for runtime JavaScript to process styles. It addresses the common performance bottlenecks associated with traditional CSS-in-JS solutions by extracting styles during the build process. This approach ensures that the browser receives optimized, static CSS, leading to faster initial page loads and improved runtime performance.

The core philosophy of Linaria revolves around leveraging modern JavaScript features and static analysis to achieve maximal performance without sacrificing developer experience. It targets developers who are building applications with frameworks like React and prefer a type-safe, developer-friendly way to manage their component styles. The library aims to provide the benefits of dynamic styling capabilities while maintaining the performance characteristics of traditional CSS.

Linaria's primary API includes tagged template literals, similar to Styled Components, but with a crucial difference: these are processed at build time. You can define styles using `css` from `@linaria/core`, which are then extracted and compiled into static CSS files. The library analyzes these template literals to determine dependencies and generate optimized output, often utilizing babel plugins for integration and extraction.

Integration is a key aspect of Linaria's design, particularly within the React ecosystem. It works seamlessly with build tools like Webpack and Vite through dedicated plugins. These plugins are responsible for the static extraction and processing of Linaria's style definitions, enabling developers to use it without significant configuration overhead in their existing build pipelines.

With a weekly download count of 487.5K and 12.3K GitHub stars, Linaria demonstrates significant adoption and community backing. Its extracted CSS approach results in exceptionally small bundle sizes, with a reported gzip size of only 358 B, signifying its efficiency and minimal impact on application payload. The library is built to offer high performance, especially in production environments where the CSS is static.

While Linaria excels at compile-time CSS extraction, developers should be aware that its primary strength is in static analysis. Dynamic features that heavily rely on runtime JavaScript evaluation for style changes might require alternative approaches or careful planning within the Linaria paradigm. The build process is essential for stylesheet generation, meaning runtime-only environments without a build step would not be compatible.

When to use

  • When aiming for optimal client-side performance by eliminating CSS-in-JS runtime overhead
  • When integrating with build systems that support Babel or Webpack plugins for static asset extraction
  • When developing React applications and seeking a template literal syntax for styling components
  • When prioritizing minimal JavaScript bundle size for critical web applications
  • When building applications where styles can be determined at compile time, including complex theming strategies
  • When migrating from other CSS-in-JS libraries to achieve better runtime performance

When NOT to use

  • If your styling needs are extremely simple and only require basic CSS without component-level logic; a global CSS file might be more straightforward.
  • In environments where a build step is not feasible or desirable; Linaria relies on compile-time processing for style extraction.
  • If you require extensive, highly dynamic style manipulations that are intrinsically tied to runtime JavaScript execution and cannot be pre-determined.
  • When working with server-side rendering frameworks that do not support build-time asset processing or CSS extraction plugins.
  • If you need a solution that injects styles purely at runtime without any build-time analysis or extraction phases.

@linaria/core Alternatives

@linaria/core Categories