# cherry
> Full documentation for cherry.
Documentation for cherry 2.0, an open source React design system in plain CSS: accessible components, light and dark mode from one brand color, zero styling runtime and Server Components ready.
---
# Introduction
> cherry 2.0 is a themeable React design system in plain CSS: zero styling runtime, Server Components ready, WCAG 2.2 AA.
Source: https://docs.cherry.al/
# cherry 2.0
cherry is a themeable React design system in plain CSS. It ships as `@cherry-design-system/react`: more than 60 components, a set of `--cherry-*` design tokens, light and dark mode, and brands built from a single accent color.
- **Plain CSS, zero styling runtime.** Every component ships static CSS in `@layer cherry`. There is no CSS-in-JS and no theme provider. Import one stylesheet, or only the files for the components you render.
- **Server Components ready.** Components without interactivity (Button, Badge, Card, Table, Prose, the layout primitives) render on the server with no client JavaScript. Interactive ones carry `"use client"` themselves, so you can import any of them from a Server Component.
- **Accessible by default.** Components meet WCAG 2.2 AA when used as documented. CI runs axe in light and dark, at desktop and 320px widths, with every popup open, and checks focus visibility, focus traps, Windows High Contrast and reflow.
- **Light and dark.** The mode is a `dark` class on ``, set before the first paint. Every color token switches with it, so a mode change re-renders nothing.
- **Brands.** `createBrand("acme", { accent: "#5b5bd6" })` derives hover, subtle, text and ring shades for both modes as validated plain CSS.
## Install
`react`, `react-dom` (18.2 or later) and `lucide-react` are peer dependencies. cherry renders its own icons with `lucide-react`, and you pass lucide icons to `icon` props, so install it alongside.
## Set up once
Import the stylesheet, run the init script in `
`, and put `cherry-root` on ``. In a Next.js App Router project:
```tsx
// app/layout.tsx
import "@cherry-design-system/react/styles.css";
import { themeInitScript } from "@cherry-design-system/react/theme-init";
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
{children}
);
}
```
Then use components anywhere:
```tsx
import { Button, ThemeToggle } from "@cherry-design-system/react";
import { Plus } from "lucide-react";
export default function Page() {
return (
}>New project
Learn more
);
}
```
See [Installation](/installation) for Vite and other React setups, router links and fonts.
## Explore
Next.js, Vite, router links, fonts and per-component CSS.
Every component with its props, examples and accessibility notes.
Light, dark and system, the init script and useColorMode.
Build a brand from one accent color with createBrand.
Semantic colors for light and dark, and the full palette.
Spacing, radius, elevation, motion, layout and typography.
Override styles with a plain class and build your own components.
What cherry guarantees and what your app must provide.
Teach coding agents to build with cherry correctly.
## Coming from 1.x
cherry 2.0 replaces `cherry-styled-components`. Read [Migrating from 1.x](/migration) for the changes to setup, props and components. The 1.x documentation is still available: pick **v1** in the version switcher.
---
# Installation
> Install cherry 2.0 and set it up in Next.js, Vite or any React app: stylesheet, init script, router links, fonts and server-side mode.
Source: https://docs.cherry.al/installation
# Installation
cherry needs three things, once: the stylesheet, a small init script in ``, and a class on ``. There is no provider to wrap your app in.
## Install the package
`react`, `react-dom` (18.2 or later) and `lucide-react` are peer dependencies. cherry renders its own internal icons with `lucide-react`, and your code imports icons from it to pass as `icon` props, so list it in your app directly.
## The three setup steps
1. **The stylesheet.** `import "@cherry-design-system/react/styles.css"` in your root layout or entry file. JavaScript never imports CSS by itself.
2. **The init script** in ``. It sets the `dark` class on `` from the visitor's preference before the first paint, so there is no flash of the wrong mode.
3. **`className="cherry-root"` on ``.** It applies the canvas color, text color and font.
## Next.js (App Router)
```tsx
// app/layout.tsx
import "@cherry-design-system/react/styles.css";
import { themeInitScript } from "@cherry-design-system/react/theme-init";
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
{children}
);
}
```
`suppressHydrationWarning` is needed because the script changes the class on `` before React hydrates.
Components without interactivity (Button, Badge, Card, Table, Prose, the layout primitives) are Server Component safe. Interactive ones carry `"use client"` themselves, so you can import any component from a Server Component.
`themeInitScript` is a static string shipped by the package, with no user input in it, which is why `dangerouslySetInnerHTML` is acceptable here. Under a strict Content Security Policy, serve it as a file or add its hash to `script-src`.
## Vite, Create React App and other client-only apps
Put the class on `` in your HTML:
```html
```
Import the stylesheet and run the init script before the first render:
```tsx
// main.tsx
import "@cherry-design-system/react/styles.css";
import { themeInitScript } from "@cherry-design-system/react/theme-init";
// Run before the first render so the first paint is already in the right mode.
const init = document.createElement("script");
init.textContent = themeInitScript;
document.head.appendChild(init);
```
## Navigation with a router
`NavItem` renders a plain ``, which reloads the page. For client-side navigation, pass your router's link with `asChild`: NavItem gives it the item's class, state and icon, and your router handles the click.
```tsx
"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { NavItem, NavPill } from "@cherry-design-system/react";
export function SiteNav() {
const pathname = usePathname();
return (
Home
Components
Docs
);
}
```
- **The current page:** pass `active` from your router (`usePathname()` in Next.js) so the server renders the highlight on the first paint. Or set `trackRoute` on NavPill and leave `active` off: it matches each link against the URL and follows route changes, but only after hydration.
- **In-page links** (`#section` or `/path#section`): `trackSections` highlights the one whose section is in view, with `aria-current="location"`. Give each target section an `id`.
- **Other routers:** the same `asChild` pattern works with React Router's ` ` and TanStack Router's ` `. The child must render an ` `.
For text links rendered by a router, give the router's link the same look as cherry's `Link` with `className="cherry-link"` plus a `data-variant` attribute. See [NavPill](/components/nav-pill) and [Link](/components/link).
## Fonts
cherry does not load font files. Its type tokens point at Geist with system fallbacks:
```css
--cherry-font-sans: Geist, ui-sans-serif, system-ui, sans-serif;
--cherry-font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
```
Load the fonts you want and point the two tokens at them in your own CSS. For example, with the Geist packages from Fontsource:
```css
/* app/globals.css */
@import "@fontsource-variable/geist";
@import "@fontsource-variable/geist-mono";
:root {
--cherry-font-sans: "Geist Variable", ui-sans-serif, system-ui, sans-serif;
--cherry-font-mono: "Geist Mono Variable", ui-monospace, monospace;
}
```
Your rule is outside `@layer cherry`, so it wins without `!important`. Every text style reads its family from these two tokens.
## Only the CSS you use
Instead of `styles.css`, import `tokens.css`, `css/base.css` and the files for the components you render:
```ts
import "@cherry-design-system/react/tokens.css";
import "@cherry-design-system/react/css/base.css";
import "@cherry-design-system/react/css/button.css";
import "@cherry-design-system/react/css/field.css";
import "@cherry-design-system/react/css/input.css";
```
Some components render others: Field renders labels, DatePicker uses Calendar and Button, Toast uses Spinner. Include those files too, or use `styles.css` while prototyping.
## The theme-color meta
The init script keeps ` ` in step with the mode, using cherry's canvas colors by default (`#ffffff` in light, `#09090b` in dark). Use your own colors, or opt out:
```ts
import { createThemeInitScript } from "@cherry-design-system/react/theme-init";
const script = createThemeInitScript({
themeColor: { light: "#ffffff", dark: "#0b0b0f" },
});
// Leaves the meta alone:
const noMeta = createThemeInitScript({ themeColor: false });
```
## Server-side mode
The visitor's choice lives in `localStorage` (`themePreference`: `light`, `dark` or `system`) and is mirrored to a `theme` cookie. Server code that needs the mode, for example to pick an image, reads the cookie with `modeFromCookie`:
```tsx
// app/hero.tsx (Server Component)
import { cookies } from "next/headers";
import { modeFromCookie } from "@cherry-design-system/react/theme-init";
export default async function Hero() {
const mode = modeFromCookie((await cookies()).get("theme")?.value);
return ;
}
```
`modeFromCookie` returns `"dark"` for a `dark` cookie and `"light"` otherwise. Nothing visual depends on it: the init script has already set the right class. See [Dark mode](/dark-mode).
## Entry points
| Import | What |
| --- | --- |
| `@cherry-design-system/react` | Components, hooks, `createBrand`, color mode helpers |
| `@cherry-design-system/react/styles.css` | All CSS (tokens, base, every component) |
| `@cherry-design-system/react/tokens.css` | Only the tokens |
| `@cherry-design-system/react/css/.css` | One component's CSS |
| `@cherry-design-system/react/theme-init` | `themeInitScript`, `createThemeInitScript`, `modeFromCookie` (server safe) |
| `@cherry-design-system/react/tokens` | Token names as typed lists (`colorTokens`, `spaceTokens`, `textStyles`, ...) |
| `@cherry-design-system/react/style-api.json` | Every class, data attribute and allowed value |
---
# Skill for AI agents
> Install the cherry-react agent skill so coding agents use cherry components, exact props, tokens and accessibility rules.
Source: https://docs.cherry.al/ai-skill
# Skill for AI agents
The cherry repository ships an agent skill in [`skills/cherry-react`](https://github.com/cherry-design-system/react/tree/main/skills/cherry-react). It teaches coding agents to build with cherry correctly: which component to use, exact props and values, `--cherry-*` tokens instead of hardcoded styles, and what accessibility needs from the app (labels, names, keyboard).
It is documentation only: no runtime code, and it is not part of the npm package.
## What it contains
```text
cherry-react/
SKILL.md # Agent Skill: rules, quick start, which component to use
AGENTS.md # self-contained guide for agents that read one file
README.md
references/
components.md # every component: props, defaults, accessibility, checked example
tokens.md # every --cherry-* token with light and dark values
setup.md # install, Next.js, Vite, per-component CSS, server-side mode
theming.md # light/dark, useColorMode, brands, overrides, custom components
accessibility.md # what cherry guarantees, what you provide, keyboard, testing
```
`components.md` and `tokens.md` are generated from the component source, the manifests and the token files. CI fails if they fall out of date, and every example in them is type-checked against the real components, so the skill matches each release.
## Install with the skills CLI
The [`skills` CLI](https://github.com/vercel-labs/skills) installs the skill into the right place for most coding agents (Cursor, Codex and others):
```bash
# into the current project
npx -y skills add cherry-design-system/react
```
Update or remove it later:
```bash
npx skills update cherry-react
npx skills remove cherry-react
```
`skills` is a third-party tool. If you would rather not use it, copy the folder by hand as described below.
## Install by hand
Clone or download the repository, then copy the `skills/cherry-react` folder into the skills directory your agent reads, either in the project (committed and shared with your team) or in your home directory (personal, every project).
## Agents that read one file
For agents without skill support, put `AGENTS.md` at your repository root, or reference it from your agent's rules file (for example `.cursor/rules` or `.github/copilot-instructions.md`). Keep the `references/` folder next to it so the agent can open the full component reference.
## What the skill enforces
The skill's rules mirror these docs:
1. Every control is a cherry component: `Button`, `IconButton`, `Input`, `Select`, `Combobox` and the rest. Never a raw ``, ` `, `` or `