# Start

Install @orz/ui, load its stylesheet, create a theme store, and render a first component.

## Install

```bash
pnpm add @orz/ui @orz/query @orz/themes lucide-react radix-ui react react-dom sonner
# only for @orz/ui/fonts.css:
pnpm add @fontsource-variable/noto-sans
# only for @orz/ui/hooks/use-overlay-scrollbars:
pnpm add overlayscrollbars
```

`radix-ui`, `sonner`, `lucide-react` and React are peer dependencies, so they are your app's own copies. Radix's focus and dismiss stacks and sonner's toast store are module state: with a second copy beside yours, Escape would stop closing a menu opened over a dialog, and `toast()` would not reach `<Toaster />`.

`@orz/themes` and `@orz/query` are `@orz/ui`'s own dependencies, installed beside it because your app imports them too: the themes below come from `@orz/themes`, and a query box's schema from `@orz/query`.

## CSS

```css
@import "tailwindcss";
@import "@orz/ui/styles.css";
```

`styles.css` brings the baseline tokens, the base layer, `tw-animate-css` and shadcn's Tailwind variants, and registers the package's own files with Tailwind, so you add no `@source` line for it.

It loads no fonts. The default style's faces are a separate import, with their own install line above:

```css
@import "@orz/ui/fonts.css";
```

`fonts.css` loads Atkinson Hyperlegible Next for Latin, Noto Sans for Cyrillic, Devanagari, Greek and Vietnamese, and OpenMono for monospace Cyrillic, Greek, Latin and Vietnamese. Chinese, Japanese and Korean come from the system, or from a font your app loads. Without it, the system's faces draw everything.

A surface that shares its document with someone else's UI imports `@orz/ui/theme.css` instead: the tokens and variants, with nothing that styles the page around it.

## Theme

A theme store holds the user's pick, paints it, and follows the OS and other tabs. It takes the themes it may show, so your bundle carries only those.

```tsx
import { builtinThemes } from "@orz/themes";
import { Toaster } from "@orz/ui/components/sonner";
import { createThemeStore, ThemeProvider } from "@orz/ui/theme";
import { createRoot } from "react-dom/client";

const themes = createThemeStore({
  storageKey: "app-theme",
  themes: builtinThemes,
});

createRoot(document.getElementById("root")!).render(
  <ThemeProvider store={themes}>
    <App />
    <Toaster />
  </ThemeProvider>,
);
```

`<ThemeMenu />` from `@orz/ui/components/theme-menu` is a ready-made picker; the one in this site's top bar is it. To keep a reload in a dark theme from flashing white, put `themePaintGuardScript({ storageKey: "app-theme" })` in an inline `<script>` in `<head>`, as every page of this site does.

## A first component

Components are imported one entry point each, so a bundler takes only those you use.

```tsx
import { Button } from "@orz/ui/components/button";
import { Label } from "@orz/ui/components/label";
import { Switch } from "@orz/ui/components/switch";
import { toast } from "sonner";

export function FirstControls() {
  return (
    <div className="flex flex-wrap items-center gap-4">
      <div className="flex items-center gap-2">
        <Switch id="wrap" defaultChecked />
        <Label htmlFor="wrap">Wrap long lines</Label>
      </div>
      <Button onClick={() => toast("Saved")}>Save</Button>
      <Button variant="outline">Cancel</Button>
    </div>
  );
}
```

A choice in the header above an example's preview shows it at the sizes of either kind of pointer, whichever device you are reading on: **Pointer** for a mouse, **Touch** for a finger, and **Auto** for the device's own.

## Build from the components

**Prefer the components as they are.** The library's point is that an app does not draw its own controls: it picks the component a guideline names for the job, and gets the density, the touch sizes, the states and the user's theme with it.

- Before using a component, read the guideline page that names it, and do what it says. The component's props are in [Storybook](/ui/storybook/).
- A `className` places a component: its position, its share of the space, the gap to its neighbours.
- Where no component fits, compose one from the library's components before drawing anything of your own.
- A light tweak on top, a muted colour from the theme's tokens, a size or a weight, is fine when it holds up in every style and theme: look at it in each. A component's own look for hover, the current place and a selection is best left to it; a style redraws those, and yours would fight it.

[Navigation](/ui/guidelines/patterns/navigation/index.md) is the worked case: a hand-made nav row draws its own current state, and an app's places then read differently from screen to screen; `NavList` draws them the same everywhere.

These rules travel with the package. `@orz/ui` ships them as an agent skill, beside every page of this site as Markdown, written for the version you installed: `node_modules/@orz/ui/skills/orz-ui/SKILL.md`, and the `docs/` next to `skills/`. One line in your project's `AGENTS.md` points a coding agent at them:

```md
Before changing UI, read node_modules/@orz/ui/skills/orz-ui/SKILL.md and follow it.
```

`npx @tanstack/intent@latest install` can write that into your agent's configuration for you.

## Packages

Each package installs on its own, with its peers and the `@orz/` packages your app imports beside it.

| Package              | Install                                                                                                                                                                                                                                                                         |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `@orz/query`         | `pnpm add @orz/query`                                                                                                                                                                                                                                                           |
| `@orz/themes`        | `pnpm add @orz/themes`                                                                                                                                                                                                                                                          |
| `@orz/ui-ansi`       | `pnpm add @orz/ui-ansi @orz/query @orz/themes @orz/ui @orz/ui-content lucide-react radix-ui react react-dom sonner`                                                                                                                                                             |
| `@orz/ui-asciinema`  | `pnpm add @orz/ui-asciinema @orz/query @orz/themes @orz/ui @orz/ui-content lucide-react radix-ui react react-dom sonner`                                                                                                                                                        |
| `@orz/ui-code`       | `pnpm add @orz/ui-code @orz/query @orz/themes @orz/ui @orz/ui-content @pierre/diffs lucide-react radix-ui react react-dom sonner`                                                                                                                                               |
| `@orz/ui-codemirror` | `pnpm add @orz/ui-codemirror @orz/query @orz/themes @orz/ui @codemirror/autocomplete @codemirror/commands @codemirror/language @codemirror/search @codemirror/state @codemirror/view @lezer/highlight lucide-react radix-ui react react-dom sonner`                             |
| `@orz/ui-content`    | `pnpm add @orz/ui-content react`; For `@orz/ui-content`, `@orz/ui-content/attachment`, `@orz/ui-content/compare`: `pnpm add @orz/query @orz/themes @orz/ui lucide-react radix-ui react-dom sonner`; For `@orz/ui-content/attachment`: `pnpm add react-dom`                      |
| `@orz/ui-hex`        | `pnpm add @orz/ui-hex @orz/query @orz/themes @orz/ui lucide-react radix-ui react react-dom sonner`; For `@orz/ui-hex/content`: `pnpm add @orz/ui-content`                                                                                                                       |
| `@orz/ui-json`       | `pnpm add @orz/ui-json @orz/query @orz/themes @orz/ui @orz/ui-content lucide-react radix-ui react react-dom sonner`; For `@orz/ui-json/toml`, `@orz/ui-json/toml/content`: `pnpm add toml-eslint-parser`; For `@orz/ui-json/yaml`, `@orz/ui-json/yaml/content`: `pnpm add yaml` |
| `@orz/ui-mail`       | `pnpm add @orz/ui-mail @orz/query @orz/themes @orz/ui @orz/ui-content lucide-react radix-ui react react-dom sonner`                                                                                                                                                             |
| `@orz/ui-markdown`   | `pnpm add @orz/ui-markdown @orz/query @orz/themes @orz/ui @orz/ui-content lucide-react radix-ui react react-dom sonner`                                                                                                                                                         |
| `@orz/ui-mermaid`    | `pnpm add @orz/ui-mermaid @orz/query @orz/themes @orz/ui @orz/ui-code @orz/ui-content @pierre/diffs lucide-react radix-ui react react-dom sonner`                                                                                                                               |

The READMEs are the full reference for each: [github.com/orzFly/ui](https://github.com/orzFly/ui), under `packages/`. Every component is also in [Storybook](/ui/storybook/), live, with its props.
