---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Colours, tokens, light and dark

Every colour, corner and text size in a Goop theme is a design token: a named value, kept once, in one stylesheet, as a CSS variable. The parts never carry a colour of their own; they read the tokens. Change a token, and every part that uses it follows, in light and in dark.

## Light and dark

Every colour token has a light value and a dark value. The page is dark when its `<html>` element has the class `dark`, and light otherwise; nothing else switches it. So a part never needs a dark version of its own.

Every Goop theme comes with the switch: a button that flips between light and dark, a menu with System, Light and Dark, and a hook for a control of your own. A short script in the page's head opens the page in the mode the reader chose last time, without a flash of the other one.

1. Open your coding agent in your project.
2. Paste this:

```agent
Add Goop's light and dark switch to this app's top bar, and open the app in the mode the reader chose last time.
```

```result
A light and dark switch in the top bar
Every part changes with it
The app opens in the reader's last choice
```

<details>
<summary>Show the exact code</summary>

The switch is `ColorModeToggle`, `ColorModeMenu` (System, Light, Dark) or `useColorMode()`, from the theme's own folder (Trail's: `@/components/ui/goop/trail/color-mode-toggle`). The script for the page's `<head>`:

```html
<script>
  try { var colorMode = localStorage.getItem('theme'); } catch (e) {}
  document.documentElement.classList.toggle('dark', colorMode === 'dark' ||
    (colorMode !== 'light' && matchMedia('(prefers-color-scheme: dark)').matches));
</script>
```

</details>

## The names

Every theme's colours carry the names shadcn/ui uses, so an agent that knows those knows these: background and foreground, card, popover, primary, secondary, muted, accent, destructive, border, input, ring, five chart colours and the sidebar's own set. Each theme adds a few of its own; Trail's are success, warning and info, a link colour, stronger and fainter text and lines, tints for a hovered or selected row, and soft fills for status badges. Trail has about 70 colour tokens in all, each with its light and its dark value.

Tailwind CSS reads them by the same names, so a class names a token, never a colour: `bg-primary`, `text-muted-foreground`, `border-border`. The corners, text sizes, shadows and control heights are tokens the same way: `rounded-lg`, `text-sm`, `h-control-md`.

## The brand colour

The accent is one token, `primary`: accent buttons, links, focus rings, checked and selected states. Its hover, the link colour and a checkbox's hover edge are worked out from it, in light and in dark. (A browser too old for CSS relative colours keeps the theme's own values for those.)

The brand colour sits in a small file of its own, `tune.css`, beside two more values: the corner base, which every corner is a step of, and the density base, which every padding, gap and control height is a step of. It holds the theme's own values. Your agent never edits it, and never writes a colour into a part.

## The stylesheets, in order

Your app's main stylesheet imports Tailwind, then the theme's stylesheets, with `tune.css` last so its values win. Your agent sets this up when it installs the first part.

<details>
<summary>Show the exact imports</summary>

Trail's, for example; every theme's follow the same order from its own folder:

```css
@import "tailwindcss";
@import "./goop/contract.css";
@import "./goop/base.css";
@import "./goop/trail/theme.css";
@import "./goop/trail/extensions.css";
@import "./goop/trail/base.css";
@import "./goop/trail/tune.css";
```

- `contract.css` gives Tailwind's names to the theme's variables (`bg-primary` is `var(--primary)`).
- `goop/base.css` is the base every part assumes: borders in the theme's border colour, the body in its background, text and typeface.
- `theme.css` holds the values: light on `:root`, dark under `.dark`.
- `extensions.css` maps the theme's own tokens beyond the shared set; its `base.css` (`goop/trail/base.css` in Trail) loads its typefaces.
- `tune.css` holds the brand colour, the corner base and the density base, imported last.

[Trail's stylesheet guide](/themes/trail/docs/stylesheets) has the rest, with the two stylesheets you import only for a choice of your own.

</details>
