Getting started

Coffee and cream, after nonovel: a serif for display, bold small labels, and a thick focus ring. Set a project up for Mocha once, then add its components and blocks from their pages.

With the CLI

One command installs Mocha's theme, fonts and shared helpers, and Lucide, the icon set its components draw with:

terminal
npx shadcn@latest add https://design.zepez.dev/r/mocha/init.json

Then add components the same way, each from its page.

Manually

1. Install the packages

terminal
npm install @fontsource-variable/baskervville@5.3.0 @fontsource-variable/montserrat@5.3.0 @fontsource/pt-mono@5.3.0 clsx@2.1.1 lucide-react@1.73.0 tailwind-merge@3.7.1

2. Add the theme

Copy Mocha's theme next to your stylesheet. It maps the system's tokens to Tailwind and sets their light and dark values.

theme.css
/* Mocha: coffee and cream, after nonovel. A serif for display, small corners, a thick focus ring. */
/*
 * Everything that makes this system look the way it does, apart from its
 * components' classes: the Tailwind mapping its components use, and the raw
 * token values for light and dark mode. No other system reads this file.
 *
 * Keep each block to plain `--name: value;` lines; the registry build reads them.
 */

@custom-variant dark (&:where([data-mode="dark"], [data-mode="dark"] *));

@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-surface: var(--surface);
  --color-surface-foreground: var(--surface-foreground);
  --color-overlay: var(--overlay);
  --color-overlay-foreground: var(--overlay-foreground);
  --color-primary: var(--primary);
  --color-primary-foreground: var(--primary-foreground);
  --color-secondary: var(--secondary);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-muted: var(--muted);
  --color-muted-foreground: var(--muted-foreground);
  --color-accent: var(--accent);
  --color-accent-foreground: var(--accent-foreground);
  --color-destructive: var(--destructive);
  --color-destructive-foreground: var(--destructive-foreground);
  --color-border: var(--border);
  --color-input: var(--input);
  --color-ring: var(--ring);
  --color-backdrop: var(--backdrop);
  --radius-sm: calc(var(--radius) * 0.5);
  --radius-md: calc(var(--radius) * 0.75);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) * 1.5);
  --font-sans: var(--body-font);
  --font-heading: var(--heading-font);
  --font-mono: var(--mono-font);
  --spacing-3xs: var(--space-3xs);
  --spacing-2xs: var(--space-2xs);
  --spacing-xs: var(--space-xs);
  --spacing-sm: var(--space-sm);
  --spacing-md: var(--space-md);
  --spacing-lg: var(--space-lg);
  --spacing-xl: var(--space-xl);
  --spacing-2xl: var(--space-2xl);
  --spacing-3xl: var(--space-3xl);
  --spacing-4xl: var(--space-4xl);
  --max-width-3xs: var(--container-3xs);
  --max-width-2xs: var(--container-2xs);
  --max-width-xs: var(--container-xs);
  --max-width-sm: var(--container-sm);
  --max-width-md: var(--container-md);
  --max-width-lg: var(--container-lg);
  --max-width-xl: var(--container-xl);
  --max-width-2xl: var(--container-2xl);
  --max-width-3xl: var(--container-3xl);
  --max-width-4xl: var(--container-4xl);
  --shadow-overlay: var(--overlay-shadow);
}

:root {
  color-scheme: light;
  --radius: 0.375rem;
  --body-font: "Montserrat Variable", ui-sans-serif, system-ui, sans-serif;
  --heading-font: "Baskervville Variable", ui-serif, Georgia, serif;
  --mono-font: "PT Mono", ui-monospace, monospace;
  --space-3xs: 0.125rem;
  --space-2xs: 0.25rem;
  --space-xs: 0.375rem;
  --space-sm: 0.5rem;
  --space-md: 0.75rem;
  --space-lg: 1rem;
  --space-xl: 1.5rem;
  --space-2xl: 2rem;
  --space-3xl: 3rem;
  --space-4xl: 4rem;
  --overlay-shadow: 0 18px 48px -16px #20130d66;

  --background: #f5e1c9;
  --foreground: #20130d;
  --surface: #f2d9b8;
  --surface-foreground: #20130d;
  --overlay: #f7e8d6;
  --overlay-foreground: #20130d;
  --primary: #382419;
  --primary-foreground: #f5e1c9;
  --secondary: #ecc790;
  --secondary-foreground: #20130d;
  --muted: #f1d7b2;
  --muted-foreground: #605145;
  --accent: #ecc790;
  --accent-foreground: #20130d;
  --destructive: #dc2626;
  --destructive-foreground: #f5e1c9;
  --border: #d5c2ad;
  --input: #cab8a3;
  --ring: #382419;
  --backdrop: #20130d99;
}

:root[data-mode="dark"] {
  color-scheme: dark;
  --background: #20130d;
  --foreground: #f5e1c9;
  --surface: #2a1a12;
  --surface-foreground: #f5e1c9;
  --overlay: #2c1c14;
  --overlay-foreground: #f5e1c9;
  --primary: #f0b557;
  --primary-foreground: #20130d;
  --secondary: #382419;
  --secondary-foreground: #f5e1c9;
  --muted: #382419;
  --muted-foreground: #b5a391;
  --accent: #382419;
  --accent-foreground: #f5e1c9;
  --destructive: #7f1d1d;
  --destructive-foreground: #f5e1c9;
  --border: #403229;
  --input: #4b3c33;
  --ring: #f0b557;
  --backdrop: #000000b3;
}

And its fonts:

fonts.css
/* The fonts this system's theme names. */
@import "@fontsource-variable/montserrat";
@import "@fontsource-variable/baskervville";
@import "@fontsource/pt-mono";

Import them after Tailwind:

globals.css
@import "tailwindcss";
@import "./fonts.css";
@import "./theme.css";

3. Copy the shared helpers

lib/utils.ts
import { type ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"

/** Joins class names and resolves conflicting Tailwind utilities, last one wins. */
export function cn(...inputs: ClassValue[]): string {
  return twMerge(clsx(inputs))
}

/** A ui-sdk part's `className`: a string, or a function of the part's state. */
export type StateClassName<State> = string | ((state: State) => string | undefined)

/**
 * Merges a component's own classes with the `className` a caller passed to a
 * ui-sdk part, keeping the caller's function form working.
 */
export function cnState<State>(
  base: ClassValue,
  className: StateClassName<State> | undefined,
): StateClassName<State> {
  if (typeof className === "function") {
    return (state) => cn(base, className(state))
  }
  return cn(base, className)
}

4. Add the ~/ alias

Components import each other and the helpers through ~/, like ~/components/ui/button. Point it at your source folder. With the CLI, set the alias in components.json instead, and it rewrites the imports to match.

tsconfig.json
{
  "compilerOptions": {
    "paths": {
      "~/*": ["./src/*"]
    }
  }
}