--- id: wiki-2026-0508-styletron title: Styletron category: 10_Wiki/Topics status: verified canonical_id: self aliases: [Styletron CSS-in-JS] duplicate_of: none source_trust_level: A confidence_score: 0.85 verification_status: applied tags: [css-in-js, styling, frontend, react] raw_sources: [] last_reinforced: 2026-05-10 github_commit: pending tech_stack: language: typescript framework: react --- # Styletron ## 매 한 줄 > **"매 atomic CSS-in-JS 의 pioneer"**. Uber 가 만든 styling library — 매 declared style 을 atomic class (`.a { color: red }`) 로 deduplicate, 매 SSR-friendly. 2026 perspective: 매 historical interest — 현재 의 mainstream 은 zero-runtime (vanilla-extract, Linaria, Panda CSS) 또는 utility (Tailwind v4). ## 매 핵심 ### 매 idea - 매 styled component 의 declared CSS 를 atomic single-property class 로 split. - 매 동일 declaration 은 한 class 의 share → 매 small bundle. - Runtime 의 dedupe + SSR 의 style extract. ### 매 Styletron 의 modern 위치 - 매 BaseWeb (Uber UI lib) 의 default styling engine. - Production 사용 의 still alive 그러나 매 new project 의 default 가 아님. - 매 atomic 의 idea 는 Tailwind / UnoCSS 가 inherit (compile-time). ### 매 modern alternatives (2026) - **vanilla-extract**: zero-runtime, type-safe. - **Panda CSS**: build-time atomic. - **Tailwind CSS v4**: 매 utility-first mainstream. - **CSS Modules + plain CSS**: 매 simplest baseline. ### 매 응용 1. BaseWeb component library 사용. 2. Legacy Uber-stack codebase 유지보수. 3. 매 historical case study (atomic CSS 의 origin). ## 💻 패턴 ### Setup (React) ```typescript import { Provider as StyletronProvider } from "styletron-react"; import { Client as Styletron } from "styletron-engine-atomic"; const engine = new Styletron(); export function App() { return ( ); } ``` ### styled component ```typescript import { styled } from "styletron-react"; const Button = styled("button", { backgroundColor: "blue", color: "white", padding: "8px 16px", borderRadius: "4px", }); // usage: ``` ### Dynamic prop-based styling ```typescript const Button = styled<"button", { $primary?: boolean }>("button", ({ $primary }) => ({ backgroundColor: $primary ? "blue" : "gray", color: "white", })); ``` ### useStyletron hook ```typescript import { useStyletron } from "styletron-react"; function Card() { const [css] = useStyletron(); return
Hello
; } ``` ### SSR (Next.js) ```typescript // pages/_document.tsx import Document, { Html, Head, Main, NextScript } from "next/document"; import { Server, Sheet } from "styletron-engine-atomic"; import { Provider } from "styletron-react"; export default class MyDoc extends Document { static async getInitialProps(ctx) { const engine = new Server(); const initialProps = await Document.getInitialProps({ ...ctx, renderPage: () => ctx.renderPage({ enhanceApp: (App) => (props) => ( ), }), }); return { ...initialProps, stylesheets: engine.getStylesheets() }; } render() { return ( {this.props.stylesheets.map((s, i) => (