style9 is a compile-time CSS-in-JS library inspired by Facebook's Stylex, extracting atomic CSS strings during build with near-zero runtime overhead. Version 0.18.2 ships TypeScript types and supports Webpack, Rollup, Next.js, Gatsby, and Vite via dedicated plugins. It uses a style.create() pattern similar to styled-components but outputs deterministic class names and minimal runtime (just a single function that maps conditions to pre-computed class strings). Unlike runtime-heavy alternatives, style9 shifts all style computation to build time, making it suitable for performance-critical applications. The library is framework-agnostic and actively maintained on GitHub.
npm install style9No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage of style9.create, conditional class names (using the variadic styles function), and minimal Webpack configuration with required plugins.
Add splitChunks configuration as shown in the quickstart. See migration guide in docs.
Use style9.create() to define styles and call the returned function with keys. See usage guide.
Define all possible style variations in style9.create() and use conditional logic in the styles() call with boolean expressions.
Update webpack to v5 and use type: 'css/mini-extract' in splitChunks cache group.
Use one of the supported bundlers (Webpack, Rollup, Next.js, Gatsby, Vite) with the appropriate plugin.
Upgrade Node.js to version 12 or later (currently >=14 recommended).
Ensure style9 is installed: npm install style9. Use require('style9/webpack') or, if using ESM, use createRequire or dynamic import.Add a rule in webpack.config.js: { test: /\.(tsx|ts|js|mjs|jsx)$/, use: Style9Plugin.loader }.Use 'import style9 from "style9"' and then style9.create(...).
Call styles() with space-separated keys or conditional boolean: styles('key1', condition && 'key2').