---
title: "Theming"
url: "https://sarthakmishra.com/riff-ui/theming"
description: "Map Riff CSS custom properties to your light and dark tokens with system-color fallbacks, and override component rules in @layer components."
image: "https://sarthakmishra.com/riff-og-image.webp"
---

[View HTML](https://sarthakmishra.com/riff-ui/theming) · [Site index](https://sarthakmishra.com/llms.txt)

# Theming

Style Riff components with CSS custom properties and @layer overrides.

Every component reads the same short list of CSS custom properties. Define them and the components follow your palette, in light and dark. Leave them out and each falls back to a system colour, so nothing renders unreadable in a bare project or in forced-colours mode.

## Properties

| Property                     | Used for                                               | Fallback       |
| ---------------------------- | ------------------------------------------------------ | -------------- |
| `--color-foreground`         | Text, active links and current rows                    | `CanvasText`   |
| `--color-muted-foreground`   | Secondary text, dates, captions and icons              | `GrayText`     |
| `--color-background`         | Surfaces such as handles, labels and buttons           | `Canvas`       |
| `--color-popover`            | The dock, its label and the search dialog              | `Canvas`       |
| `--color-muted`              | Hover and selected fills, boards and frames            | `ButtonFace`   |
| `--color-border`             | Edges, dividers and rails                              | `GrayText`     |
| `--color-primary`            | Accents: the reading trail, the active date, the robot | `Highlight`    |
| `--color-primary-foreground` | The robot’s eyes                                       | `Canvas`       |
| `--color-ring`               | Focus rings                                            | `Highlight`    |
| `--font-mono`                | Keyboard hints                                         | `ui-monospace` |

shadcn projects already define most of these names, so components installed there pick up the theme with no extra work. The video player keeps its own dark chrome so its controls stay legible over any frame.

## Map your tokens

If your tokens use other names, alias them once at the root:

```css
:root {
  --color-foreground: var(--text-primary);
  --color-muted-foreground: var(--text-secondary);
  --color-background: var(--surface-0);
  --color-popover: var(--surface-1);
  --color-muted: var(--surface-2);
  --color-border: var(--line);
  --color-primary: var(--brand);
  --color-ring: var(--brand);
}
```

For dark mode, change the values, not the names. `light-dark()` keeps both themes in one declaration:

```css
:root {
  color-scheme: light dark;
  --color-primary: light-dark(#ca3800, #ff6a2b);
}
```

## Override a component

The rules live in `@layer components`. Any unlayered rule, or a rule in a later layer, wins without `!important`:

```css
/* app.css, unlayered */
.riff-tree {
  --riff-tree-indent: 1rem;
}
```

Many components expose their own `--riff-*` properties for sizes like this; each page’s Usage section names them. Because the files are yours, you can also edit them directly. Prefer the custom properties for colour, so a later reinstall keeps your theme.

## Motion

Components animate to explain a change: a folder unfolds to its height, the reading trail follows the sections on screen, a new theme spreads from the toggle. Transitions stay short on a strong ease-out curve, and `prefers-reduced-motion` turns travel off.

## Structured data

```json
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "WebSite",
      "@id": "https://sarthakmishra.com/#website",
      "url": "https://sarthakmishra.com/",
      "name": "Sarthak Mishra",
      "publisher": {
        "@id": "https://sarthakmishra.com/#person"
      },
      "inLanguage": "en"
    },
    {
      "@type": "Person",
      "@id": "https://sarthakmishra.com/#person",
      "name": "Sarthak Mishra",
      "url": "https://sarthakmishra.com/about",
      "jobTitle": "Design Engineer",
      "image": "https://sarthakmishra.com/og-images/sarthak-mishra.webp",
      "sameAs": [
        "https://github.com/SarthakMishra",
        "https://www.linkedin.com/in/itssarthakmishra/",
        "https://x.com/MishraMishry"
      ]
    },
    {
      "@type": "WebPage",
      "@id": "https://sarthakmishra.com/riff-ui/theming#webpage",
      "url": "https://sarthakmishra.com/riff-ui/theming",
      "name": "Theming - Riff UI React Components",
      "description": "Map Riff CSS custom properties to your light and dark tokens with system-color fallbacks, and override component rules in @layer components.",
      "inLanguage": "en",
      "isPartOf": {
        "@id": "https://sarthakmishra.com/#website"
      },
      "about": {
        "@id": "https://sarthakmishra.com/#person"
      }
    }
  ]
}
```
