OwODocs

Styling / CSS

Explore the different styling approaches we can take in mono-repos.

Jan 10, 2025

  • Styles
  • UI
  • CSS

CSS Modules

  • Component-scoped styling
  • Traditional CSS workflows
  • Projects requiring CSS isolation
  • Teams familiar with standard CSS
  • Design systems with strict scoping needs

Native CSS with automatic scoping. Strong TypeScript integration via CSS module declarations. No runtime overhead. Supports all CSS features and tooling. Main limitations are sharing styles across modules and dynamic styling. Best for teams wanting traditional CSS with scoping benefits.

Tailwind CSS

  • Rapid prototyping needs
  • Design systems with consistent constraints
  • Projects prioritizing development speed
  • Teams wanting minimal context switching
  • Applications with repeated design patterns

Utility-first approach with zero runtime. Excellent IDE support and TypeScript integration. Highly customizable design system. Initial setup complexity and larger HTML classes. Learning curve for utility patterns. Ideal for teams wanting rapid development with consistent design constraints.

Styled Components

  • React-specific styling needs
  • Dynamic, prop-based styling
  • Component libraries
  • Teams preferring CSS-in-JS
  • Applications requiring runtime styling

Component-level CSS-in-JS with strong TypeScript support. Dynamic styling based on props. Good developer experience with template literals. Runtime performance overhead. Bundle size implications. Best for React applications needing dynamic styles.

Emotion

  • Cross-framework compatibility
  • Performance-critical applications
  • Design systems requiring CSS-in-JS
  • Projects needing styled-components alternative
  • Applications with complex theming

Similar to styled-components with better performance. Framework agnostic. Strong TypeScript support. Smaller runtime than styled-components. Still has CSS-in-JS overhead. Good for applications needing CSS-in-JS with better performance.

Stitches

  • Performance-focused applications
  • Design systems with variants
  • Near-zero runtime styling needs
  • Type-safe component styling
  • Applications requiring SSR

Zero-runtime CSS-in-JS with variants support. Excellent TypeScript integration. Better performance than traditional CSS-in-JS. Limited dynamic styling capabilities. Newer with smaller ecosystem. Ideal for applications prioritizing performance.

Vanilla Extract

  • Build-time CSS-in-JS
  • Type-safe styling needs
  • Zero runtime requirements
  • Design systems with themes
  • Static styling needs

Zero runtime CSS-in-JS with full TypeScript support. CSS modules-like scoping with JavaScript/TypeScript API. No runtime overhead. Limited dynamic styling. Build process complexity. Best for applications needing type-safe CSS without runtime cost.

SASS/SCSS

  • Legacy projects
  • Complex CSS requirements
  • Teams with SASS expertise
  • Design systems using mixins
  • Projects requiring CSS preprocessing

Extended CSS functionality with variables and mixins. Mature ecosystem and tooling. No runtime overhead. Requires preprocessing setup. Less modern than alternatives. Good for teams familiar with SASS or complex CSS needs.

CSS-in-JS (Generic)

  • Dynamic styling requirements
  • Component libraries
  • Theme-heavy applications
  • Runtime style modifications
  • Cross-platform styling needs

Runtime style generation with JavaScript. Strong dynamic capabilities. Good developer experience. Performance overhead. Bundle size impact. Suitable for applications requiring highly dynamic styles.

UnoCSS

  • Atomic CSS needs
  • Performance-critical applications
  • Custom utility patterns
  • Tailwind alternative
  • Build-time optimization needs

Atomic CSS engine with high performance. Fully customizable utilities. Smaller bundle than Tailwind. Newer with less community support. Learning curve for configuration. Good for teams wanting customizable atomic CSS.

ChakraUI / MUI (Styling System)

  • Rapid application development
  • Consistent design systems
  • Component-heavy applications
  • Teams needing pre-built components
  • Projects with design system requirements

Complete styling and component system. Strong TypeScript support. Extensive pre-built components. Larger bundle size. Design customization complexity. Best for teams needing full design systems with components.