Stylex Vs. Tailwind: Meta’s Take On Css-in-js Maintainability

Sedang Trending 2 jam yang lalu

Tailwind has been successful nan news lately, arsenic it struggles to support its doors unfastened successful nan AI era. But it’s not nan only “CSS-in-JS” solution to compete for developers’ attention. Recently Meta has been promoting its unfastened source, React-based styling project, StyleX. Unlike Tailwind, it’s not a model — Meta calls it some a JavaScript library and, much broadly, a “system.” But regardless, StyleX is yet different replacement to straight utilizing nan style expanse connection CSS (Cascading Style Sheets).

In a blog post toward nan extremity of past year, Meta’s Melissa Liu called StyleX a “styling strategy for large-scale applications.” Liu is simply a React components package technologist and a halfway personnel of nan StyleX task astatine Meta. In her blog post, she notes that StyleX has go “the modular styling strategy crossed Meta products for illustration Facebook, Instagram, WhatsApp, Messenger and Threads, arsenic good arsenic outer companies for illustration Figma and Snowflake.”

A speedy statement astir CSS-in-JS: These are solutions successful which developers specify style utilizing JavaScript, alternatively than CSS. But astatine a clip erstwhile CSS itself is becoming ever much sophisticated — Google’s CSS Wrapped 2025 listed 22 caller CSS features successful Chrome past twelvemonth — why is location a request for Javascript-based styling systems?

At slightest for Meta, nan reply is: standard and codification maintainability.

The Challenge of Styling astatine Scale

This week, Liu went connected nan Meta Tech Podcast to talk StyleX pinch her workfellow Pascal Hartig. She noted that Facebook’s website is made up of “thousands of components” — including, nary doubt, a ample number of styling components — and it must header pinch “hundreds of millions of users” each day. She explained that this benignant of complexity and standard demanded a amended measurement to negociate styling.

“We besides request to deliberation astir what’s maintainable from a developer perspective,” she said. “Of being capable to person this ample codification guidelines and make it truthful that … if personification from nan ads squad is building a component, that they’re declaring … a fastener people there; and then, oh, personification from Instagram is besides creating a fastener class….and [so] we request a strategy … to benignant of make it maintainable.”

The accusation is that penning CSS codification is, by itself, insufficient erstwhile it comes to a monolithic website for illustration facebook.com, not to mention erstwhile it integrates pinch different apps, for illustration Instagram aliases Threads. The problem present is that CSS is global; if, arsenic Liu said, personification from nan Meta ads squad changes a fastener people successful CSS, it mightiness inadvertently override aliases conflict pinch an Instagram fastener class.

In her blog post, Liu explained nan issues pinch utilizing consecutive CSS earlier StyleX (and a precursor named cx) came along:

“Serving CSS astatine specified a standard resulted successful collisions crossed bundles, difficulties successful managing limitations betwixt stylesheets and challenges successful reconciling competing rules that often led to specificity wars.”

How StyleX Compares to Tailwind

So really does StyleX work? As noted above, it’s a JavaScript room — and truthful you’re penning successful JavaScript codification alternatively of nan CSS language. Since this is Meta, StyleX has been optimized for React, but successful an FAQ Meta insists that it is framework-agnostic:

“StyleX is simply a CSS-in-JS solution, not a CSS-in-React solution. Although StyleX has been tailored to activity champion pinch React today, it is designed to beryllium utilized pinch immoderate JavaScript model that allows authoring markup successful JavaScript.”

“At its core, StyleX is simply a compiler that extracts styles astatine build clip and generates a fixed stylesheet.”
— Melissa Liu, Core StyleX developer astatine Meta

Liu noted successful her blog station that “at its core, StyleX is simply a compiler that extracts styles astatine build clip and generates a fixed stylesheet.” So nan extremity consequence is CSS, but that comes via JavaScript and nan processing of that (into CSS) is done astatine build time.

Tailwind is besides a CSS-in-JS solution, and location are immoderate similarities to StyleX. Tailwind allows nan developer to create “utility classes” wrong nan HTML file, which are past turned into a fixed CSS record astatine build. The quality is mostly successful nan syntax: Tailwind uses its ain typical classNames, whereas StyleX uses JavaScript objects.

Mainly because of its unsocial syntax, maintainability has agelong been a contentious rumor pinch Tailwind. In a 2023 article, I noted that galore developers dislike nan disfigured markup that Tailwind imposes connected HTML, which successful move makes nan codebase much difficult to maintain.

Although Liu only concisely mentioned Tailwind connected nan Meta Tech Podcast, she seems to person nan aforesaid concerns astir maintainability. She acknowledged that developers emotion really speedy it is to activity with, but adds that “you suffer retired connected maintainability pinch systems for illustration Tailwind.”

“While Tailwind is very overmuch CSS-in-JS, arsenic a syntax, it’s not very bully astatine being CSS-in-JS.”
— Naman Goel, Core StyleX developer astatine Meta

Others successful nan StyleX squad are much critical. One of nan co-creators of StyleX (and still a halfway developer), Naman Goel, wrote a station connected his individual blog past September arguing that Tailwind is “bad astatine being CSS-in-JS” because of its syntax:

“While nan className abstraction is awesome for quickly prototyping styles, it falls isolated extracurricular of nan communal use-cases. Writing CSS keyframes, position transitions, anchor positioning and thing retired of nan mean intends reaching for an existent CSS file.”

Of course, web standards advocates would opportunity there’s thing incorrect pinch going backmost to nan root code: CSS. But Goel’s constituent is that pinch StyleX, you tin (apparently) screen each your styling needs pinch JavaScript.

The Rise of Atomic CSS

As Goel notes successful a follow-up post, some StyleX and Tailwind are examples of what’s go known arsenic “atomic CSS” styling. According to nan archiving of yet different CSS-in-JS solution, called Compiled, atomic CSS is “a method of reducing nan full magnitude of defined rules by creating a azygous norm (and successful turn, a unsocial people name) for each declaration – enabling ample style re-use.”

“At nan bosom of StyleX is its fixed compilation into atomic CSS.”
— Liu

For StyleX, atomic CSS is simply a cardinal portion of its solution. Per Liu’s blog post:

“At nan bosom of StyleX is its fixed compilation into atomic CSS. Styles are converted to classes containing a azygous style declaration for reuse crossed a codebase truthful CSS size plateaus arsenic nan exertion grows.”

In his station astir atomic CSS, Goel points retired that location are various ways “to bundle and service atomic CSS.” But again, this seems to beryllium applicable only to websites aliases applications that person a certain, very rare, scale. Even Goel admits that usually a azygous CSS record useful best:

“Having a azygous CSS bundle for your full web app is almost ever a decent solution. If Facebook.com tin get distant pinch it, it’s astir apt accelerated enough.”

What’s Next for StyleX?

At nan extremity of 2025, StyleX launched a caller website. Accompanying it was a blog post, credited to some Goel and Liu. They wrote that nan “new website is built pinch Waku, a minimal React model that lets america use from, and showcase StyleX’s compatibility pinch React Server Components.” (The New Stack profiled Waku a mates of years ago, soon aft it came out.)

The brace added that successful 2026, StyleX will get “better ergonomics, caller characteristic work, and developer tooling.”

StyleX is simply a CSS-in-JS strategy to support an oculus on, particularly if you’re heavy successful nan React ecosystem. But unless you’re moving a website aliases app nan standard of Facebook.com, you’re astir apt amended disconnected sticking pinch Tailwind aliases (even better) dealing straight pinch nan CSS language.

YOUTUBE.COM/THENEWSTACK

Tech moves fast, don't miss an episode. Subscribe to our YouTube channel to watercourse each our podcasts, interviews, demos, and more.

Group Created pinch Sketch.

Selengkapnya