Menu

Getting started

Theming

Every color in centerUI is a semantic token, so changing the look of the whole library means editing a handful of CSS variables.

Tokens

Each token has a light and a dark value. Foreground pairs (for example primary-fg) are the readable text color on top of their background. Each color is written five ways, as it is in the theme now: press a button to copy a code.

  • bg

    Page background

    OKLCH…
    HEX…
    RGB…
    HSL…
    HSB…
  • fg

    Default text

    OKLCH…
    HEX…
    RGB…
    HSL…
    HSB…
  • card

    Raised surfaces

    OKLCH…
    HEX…
    RGB…
    HSL…
    HSB…
  • muted

    Subtle backgrounds

    OKLCH…
    HEX…
    RGB…
    HSL…
    HSB…
  • muted-fg

    Secondary text

    OKLCH…
    HEX…
    RGB…
    HSL…
    HSB…
  • border

    Borders and dividers

    OKLCH…
    HEX…
    RGB…
    HSL…
    HSB…
  • ring

    Focus ring

    OKLCH…
    HEX…
    RGB…
    HSL…
    HSB…
  • primary

    Primary actions

    OKLCH…
    HEX…
    RGB…
    HSL…
    HSB…
  • secondary

    Secondary actions

    OKLCH…
    HEX…
    RGB…
    HSL…
    HSB…
  • danger

    Destructive actions

    OKLCH…
    HEX…
    RGB…
    HSL…
    HSB…
  • success

    Positive states

    OKLCH…
    HEX…
    RGB…
    HSL…
    HSB…
  • warning

    Cautionary states

    OKLCH…
    HEX…
    RGB…
    HSL…
    HSB…

Using tokens

Tokens are registered with Tailwind, so they work in any utility.

<div className="rounded-lg border bg-card p-4 text-card-fg">
  <p className="text-muted-fg">Secondary text</p>
</div>

Customizing

Override the variables in your global stylesheet. Components pick the change up automatically.

:root {
  --primary: light-dark(oklch(0.55 0.2 260), oklch(0.72 0.15 260));
  --primary-fg: oklch(0.985 0 0);
  --radius: 0.75rem;
}

Dark mode

Values are resolved with light-dark(), so the theme follows the operating system by default. Set a class on the html element to force one.

<html class="dark">   <!-- always dark  -->
<html class="light">  <!-- always light -->
<html>                <!-- follows the OS  -->