Vanilla Extract
ELI5 — The Vibe Check
Vanilla Extract is CSS-in-JS with zero runtime cost. You write styles in TypeScript files at build time, and they compile to plain CSS class names. You get type-safe styles, theme variables, and all the CSS-in-JS DX without shipping a single byte of styling JavaScript to the browser.
Real Talk
Vanilla Extract is a zero-runtime CSS-in-TypeScript library. Styles are written in .css.ts files and compiled to static CSS at build time, producing standard class names. It provides type-safe themes, dynamic variants via the Sprinkles API (like type-safe Tailwind), and composes well with any framework.
Show Me The Code
// styles.css.ts
import { style } from '@vanilla-extract/css';
export const button = style({
background: 'blue',
color: 'white',
':hover': { background: 'darkblue' },
});
// Component.tsx
import { button } from './styles.css';
<button className={button}>Click</button>
When You'll Hear This
"Vanilla Extract gives us type-safe styles that compile to zero-runtime CSS" / "Sprinkles from vanilla-extract is basically type-safe Tailwind"
Related Terms
CSS-in-JS
CSS-in-JS is the controversial philosophy of writing your styles in JavaScript instead of CSS files. Fans love the co-location and dynamic styling.
CSS Modules
CSS Modules are like giving every CSS class a unique ID badge so they never clash with each other.
Emotion
Emotion is CSS-in-JS that gives you two flavors: the styled-components-like syntax AND a css prop for inline styles.
Styled Components
Styled Components lets you write CSS right inside your JavaScript using tagged template literals.