# Themes

## Overview

A theme is one CSS file: a [custom stylesheet](/help/advanced/stylesheets) that restyles the whole app rather than one corner of it. Themes are CSS only, so no code runs, and Garnet refuses any stylesheet that would load something from the internet. That makes a theme file safe to use wherever you found it.

To use a theme:

1. Download its `.css` file, from [the themes on this page](#themes) or from anyone who shares one.
2. In the app, open Settings › Appearance › Advanced › Custom stylesheet and choose **Add CSS file…**.
3. Pick the file. Garnet copies it into your Space's `.garnet/styles/` folder, selects it and turns on **Use custom CSS**.

On a phone it can be easier to copy the CSS instead: choose **Show the CSS** and copy it, then in the app choose **Paste CSS…**, give it a name, paste, and choose **Add**.

You can also save the file into `.garnet/styles/` yourself, then pick it under **Stylesheet** and turn on **Use custom CSS**.

A theme sits on top of the theme style, accent and display mode you pick in Appearance. If one breaks the layout, turn off **Use custom CSS**; your own theme style and accent come back.

## Write a theme

Start from the variables. Most themes need nothing else:

```css
/*
 * @name Harbour
 * @author Your Name
 * @description Cool blue-grey surfaces with a softer card edge, in light and dark mode.
 * @modes both
 * @version 1.0.0
 * @license MIT
 */

[data-mode="light"] {
  --garnet-color-bg: oklch(0.97 0.01 240);
  --garnet-color-surface: oklch(0.985 0.006 240);
  --garnet-color-surface-elevated: oklch(0.995 0.003 240);
}

[data-mode="dark"] {
  --garnet-color-bg: oklch(0.2 0.015 240);
  --garnet-color-surface: oklch(0.24 0.015 240);
  --garnet-color-surface-elevated: oklch(0.28 0.015 240);
}

.garnet-card {
  border-radius: 1rem;
}
```

- **Light and dark:** Garnet sets `data-mode="light"` or `data-mode="dark"` on the `html` element. Scope colours to each. A theme for one mode only scopes every rule to it and leaves the other mode as the theme style draws it.
- **Override variables first.** Set `--garnet-*` variables on `[data-mode]` or `:root`. Variables you leave alone keep the theme style's values, so text sizes, density and contrast settings still work.
- **Style hooks second.** Where a variable is not enough, select a documented `garnet-*` class. Never select generated class names or element order.
- **Leave the accent alone.** The accent marks New, the selection and links. Do not tint surfaces, borders or focus rings with `--garnet-color-primary`.
- **Check both modes and every contrast setting.** Try each contrast setting and text size in Appearance before you share a theme.

The full list of variables, root attributes and hooks is in [Custom stylesheets](/help/advanced/stylesheets).

## Header block

A theme can start with one comment block of `@key value` lines, so people can tell what the file is. Every key is optional.

| Key | Value |
| --- | --- |
| `@name` | The theme's name. |
| `@author` | Your name or handle. |
| `@description` | One sentence on what it looks like and which modes it changes. |
| `@modes` | `light`, `dark` or `both`. |
| `@version` | A version number, such as `1.0.0`. Raise it with every change. |
| `@license` | The licence you share it under, such as `MIT` or `CC0-1.0`. |

## Share a theme

Share the `.css` file however you like: a link, a gist, a forum post. Before you do, check it in both modes and with every contrast setting and text size in Appearance, and make sure sync conflict notices, Doctor warnings, App Lock, confirmations and focus rings all stay visible.
