StyleX: Facebook's CSS-in-JS Compiler and When to Choose It Over Tailwind
StyleX is the styling system for ambitious user interfaces.
At a glance
- What is it?
- StyleX is a JavaScript styling library from Meta that compiles styles into atomic CSS at build time. This review covers what it solves, how the Babel plugin works, how to build the monorepo, and where it falls short.
- Who is it for?
- StyleX suits teams already running a Babel or bundler pipeline who want component-scoped styles without a runtime style engine, and who accept that the compiler is where the work happens. It is the wrong choice if your toolchain cannot host the Babel plugin.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository received new commits within the last day.
- What is it written in?
- Mainly JavaScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 13, 2026, and from our analysis. They are not legal advice.
Star history
- facebook/stylex10,493 ★ · +146
| Repository | 2026-09-22 | 2026-11-13 |
|---|---|---|
| facebook/stylex | 10.3k | 10.5k |
146 Stars in the last 52 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
The problem StyleX solves, and who it is actually for
Most CSS-in-JS libraries resolve styles in the browser. StyleX does not. The README describes it as "a JavaScript library for defining styles for optimized user interfaces," and the monorepo layout makes the intent visible: the packages directory contains a Babel plugin, a PostCSS plugin, a Rollup plugin, an ESLint plugin and a CLI, alongside the runtime package @stylexjs/stylex. The styling is authored in JavaScript, then compiled away before it reaches the browser.
That places StyleX between two familiar camps. It is not a utility-class framework where the class names are the API, and it is not a runtime CSS-in-JS library where a style object is serialized on every render. The audience is teams with a build pipeline they control and a component model where styles belong next to markup. The repository ships examples for Vite, Webpack, Rollup, esbuild, Rspack, Next.js, React Router, RedwoodSDK, Waku, Storybook and SvelteKit, which tells you the project expects to be wired into an existing bundler rather than to replace it.
How the compiler turns stylex.create into atomic CSS
The README example is short, and the whole mechanism is visible in it. You call stylex.create with an object of named style rules, then pass those rules to stylex.props and spread the result onto an element.
import * as stylex from '@stylexjs/stylex';
const styles = stylex.create({
root: {
padding: 10,
},
element: {
backgroundColor: 'red',
},
});
const styleProps = stylex.props(styles.root, styles.element);The important part is what happens to those objects at build time. The Babel plugin in packages/@stylexjs/babel-plugin is the piece that reads stylex.create calls and emits CSS, so the style objects do not survive into the bundle as data to be processed at runtime. The runtime package supplies the API surface; the compiler supplies the output. The CLI package and the PostCSS, Rollup and unplugin packages exist because different build tools need different entry points into that same compiler.
The project points contributors at its goals and architectural principles before they propose API changes.
Installing StyleX and writing a first compiled style
The repository is a monorepo managed with Yarn 1.22.22, and the root README directs you to the documentation website and to the README of the individual packages, starting with @stylexjs/stylex. To work on the project itself rather than consume it, the README says to run yarn install first, which triggers a postinstall build across the workspaces.
yarn installAfter that, the root package.json exposes the workspace scripts. Building every package runs the build script in each one, and the test target chains the build, the Flow check, the package tests, a Prettier report and an ESLint report in that order.
yarn build
yarn testTo build or test a single package, the README gives the workspace form, substituting the package name:
yarn workspace <package-name> build
yarn workspace <package-name> testFor application use rather than repository development, the README does not include install instructions for the published packages. It points to the documentation website and to the per-package README files, and the examples directory holds working integrations for each bundler. If you want to see a minimal working setup, the example-vite or example-webpack directories in examples/ are where to look before writing your own configuration.
Where StyleX stops being the right tool
Compilation is the trade-off.
The second constraint is toolchain coupling. StyleX is not a single dependency you drop in. The monorepo ships a Babel plugin, a PostCSS plugin, a Rollup plugin, a CLI and an unplugin package, and the examples list shows separate integration paths for Vite, Webpack, esbuild, Rspack, Next.js, React Router, RedwoodSDK, Waku, Storybook and SvelteKit. If your build setup is not among those, you are writing the integration yourself. The README does not document a fallback path for a bundler without one of these plugins.
The third is the design constraints the project asks contributors to learn. The contributing guide asks contributors to read the goals and architectural principles before proposing API changes, which is a signal that the API is opinionated rather than permissive. Teams expecting to write arbitrary CSS in a JavaScript object will find the compiler rejecting or reshaping what they write.
StyleX versus Tailwind: two answers to the same question
The difference between StyleX and Tailwind is structural rather than cosmetic. Tailwind puts the design decisions in class names written directly in markup, and the CSS is generated from a configuration file scanned for those class names. StyleX puts the design decisions in JavaScript objects passed to stylex.create, and the CSS is generated by a compiler that understands the component that owns those objects.
That changes where reuse lives. In Tailwind, reuse means extracting a component or writing a shared class string. In StyleX, reuse means exporting a style object from a module and merging it with stylex.props, which accepts multiple arguments as the README example shows. The compiler then resolves the merge.
The other difference is where conflicts are settled. Tailwind relies on the order of generated utilities and on specificity rules you have to reason about when overriding. Neither approach is strictly better; they fail in different places.
Maintenance, release cadence and the MIT licence
The repository is not archived, and the last push was on 2026-11-02. Recent releases listed are 0.19.1 on 2026-09-15, 0.17.5 on 2026-01-21 and 0.17.4 on 2025-12-23. The gap between 0.17.5 in January and 0.19.1 in September is worth noting if you plan to pin a version: the minor line moved twice across that period, and the project is still on a 0.x version, which by convention means the API is not yet declared stable.
StyleX is MIT licensed, and the repository carries a LICENSE file at the root. MIT is permissive, so the practical implication for most teams is attribution rather than copyleft obligations. That is a statement about the licence text, not legal advice; if your organisation has rules about bundled dependencies or about Meta-authored code, run it past whoever handles that.
The upgrade cost is tied to the compiler rather than the runtime. Because StyleX is still on a 0.x version, a version bump can change emitted CSS as well as the JavaScript API. Pinning @stylexjs/babel-plugin and the runtime package to matching versions, and re-running your snapshot tests after a bump, is the practical mitigation. The repository's own test script runs the build, Flow, package tests, Prettier and ESLint together, which is the shape of check you would want in your own pipeline before shipping a compiler upgrade.
Editorial conclusion
StyleX suits teams already running a Babel or bundler pipeline who want component-scoped styles without a runtime style engine, and who accept that the compiler is where the work happens. It is the wrong choice if your toolchain cannot host the Babel plugin. Before adopting, verify that your bundler integration exists in the examples directory, check the version of @stylexjs/babel-plugin you would pin, and confirm your team can read the thinking-in-stylex design constraints before writing the first style object.
Frequently asked questions
How do I install StyleX?
The README does not give install commands for the published packages; it points to the documentation website and to the README of @stylexjs/stylex. For the monorepo itself, the README says to run yarn install first, which triggers the postinstall build across the workspaces.
What is StyleX?
StyleX is a JavaScript library for defining styles for optimized user interfaces, described in the repository description as the styling system for ambitious user interfaces. Styles are written with stylex.create and applied with stylex.props, and the repository is the development monorepo containing the Babel, PostCSS, Rollup, ESLint and CLI packages.
How do I use StyleX?
You define a style object with stylex.create and pass the named rules to stylex.props, then spread the returned props onto an element. The README example creates a root rule with padding and an element rule with a background colour, then merges both in a single stylex.props call.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/facebook-stylex)Star history chart for your README
[](https://hysenlabs.com/projects/facebook-stylex)Was this useful?