A performant, flexible CSS-in-JS library for styling apps with string or object styles and predictable style composition.
facebook/stylex
A JavaScript styling library from Facebook for defining optimized, atomic CSS styles in user interfaces.
- Stars
- 10,424
- Forks
- 502
- Open issues
- 239
- Last commit
- 4 hours ago
What is it?
StyleX is a JavaScript library for defining styles in user interfaces. Developers declare styles with stylex.create and apply them with stylex.props, which returns the class names to attach to elements.
The project is a development monorepo that includes the core stylex package along with a Babel plugin, a CLI, PostCSS, Rollup and ESLint plugins, a style value parser, and a documentation site at stylexjs.com. Examples show integration with build tools.
Styles are written as JavaScript objects, and the tooling compiles them during the build step.
Key features
- 01Defines styles as JavaScript objects with stylex.create.
- 02Applies styles to elements through stylex.props.
- 03Ships a Babel plugin and integrations for PostCSS, Rollup and ESLint.
- 04Includes a CLI for the build workflow.
- 05Provides an official documentation website.
Use cases
- Styling a React or other JavaScript UI with co-located, scoped style definitions.
- Adding a build-time styling pipeline to an existing frontend project using Rollup or PostCSS.
- Enforcing style conventions in a codebase with the StyleX ESLint plugin.
Quick start
- 1
Install the StyleX package from npm
npm install @stylexjs/stylex - 2
Define styles with stylex.create and apply them with stylex.props
- 3
Read the documentation website for build tool setup
Things to know
- The README gives no setup for compiling styles; build tool integration must be configured separately.
- This is a monorepo for development, so contributing requires installing the full yarn workspace.
Topics
FAQ
- What is stylex?
- A JavaScript styling library from Facebook for defining optimized, atomic CSS styles in user interfaces. StyleX is a JavaScript library for defining styles in user interfaces. Developers declare styles with stylex.create and apply them with stylex.props, which returns the class names to attach to elements.
- Is stylex free to use? What license does it have?
- stylex is open source under the MIT license. Check the license terms before using it in commercial products.
- Is stylex still maintained?
- Actively maintained. The last commit to stylex was on Oct 21, 2026.
- What can I use stylex for?
- Styling a React or other JavaScript UI with co-located, scoped style definitions. Adding a build-time styling pipeline to an existing frontend project using Rollup or PostCSS. Enforcing style conventions in a codebase with the StyleX ESLint plugin.
- How do I install stylex?
- Install the StyleX package from npm: npm install @stylexjs/stylex Define styles with stylex.create and apply them with stylex.props Read the documentation website for build tool setup
- Where can I get stylex?
- The source code and installation instructions are on GitHub: https://github.com/facebook/stylex
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A JavaScript library for building interactive user interfaces from composable components, usable on the web, server and native platforms.
Popular front-end framework of HTML, CSS and Sass/JavaScript components for building responsive, mobile-first websites.
A Material Design UI component framework for Vue, providing handcrafted, responsive components for building web applications.
A Rust framework for building web, desktop, and mobile apps from a single codebase, with React-like components and signals.
A starter template for building cross-platform desktop apps with Electron, React, TypeScript, and Vite.