Skip to main content

addBase()

Add base styles to the @layer base layer. Base styles are applied globally before utilities and components.
CssInJs
required
CSS-in-JS object containing base styles for HTML elements

Basic Example

Compiles to:

Reset Styles

Using Theme Values

Custom Fonts

Multiple @font-face Declarations

Keyframes from Theme

Normalize Lists

addComponents()

Add component styles. This is an alias for addUtilities() with the same behavior.
Record<string, CssInJs> | Record<string, CssInJs>[]
required
CSS-in-JS object containing component class definitions
object
Optional configuration (reserved for future use)

Basic Example

Card Component

Using Theme Values

Array of Components

Form Components

matchComponents()

Register dynamic components. This is an alias for matchUtilities() with the same behavior.
Record<string, (value: string, extra: { modifier: string | null }) => CssInJs>
required
Object mapping component names to functions that return CSS styles
object
Configuration for values, types, and modifiers (same as matchUtilities)

Example

Base vs Components vs Utilities

Choosing the Right Layer

  • Use addBase for:
    • Element resets and normalizations
    • Default typography styles
    • Font declarations
    • Global keyframe animations
  • Use addComponents for:
    • Complex UI patterns
    • Pre-composed styles
    • Third-party integrations
  • Use addUtilities for:
    • Single-purpose classes
    • Property-value mappings
    • Missing CSS properties
Base styles are not affected by variants (hover, focus, etc.). Use components or utilities if you need variant support.