# Nook > Nook is a free, open source (MIT) React component library. Components are copied into your project with a CLI, styled with Tailwind CSS v4 and themed with CSS variables. Phase 1 supports React and Next.js. ## Concepts - Code is copied into the user's project with `npx nook-ui@latest add ` (also `pnpm dlx`, `bunx --bun`, `yarn dlx`). The command is `nook`; the npm package is `nook-ui`. - Run `nook init` once. It writes `nook.json`, adds the tokens and theme to the global CSS file between `nook:tokens` and `nook:theme` markers, and adds `cn()` in `lib/utils`. - Components read CSS variables: background, foreground, card, popover, primary, secondary, muted, accent, destructive (each with -foreground), border, input, ring, radius, font-body, density, elevation-1..3. Use Tailwind classes such as `bg-primary`, `text-muted-foreground`, `rounded-lg`, `h-control`. - Components are compound: `Card`, `CardHeader`, `CardTitle`. Variants live in one `cva` call. Pass `className` to override; classes are merged with tailwind-merge. - Dark mode: add the `dark` class to an ancestor such as ``. - Icons come from one module (`@/components/icons`). Decorative icons are `aria-hidden`; icons that carry meaning need a `label`. - Accessibility target is WCAG 2.1 AA. Label every input, give icon-only buttons an `aria-label`, and connect errors with `aria-describedby`. - Overlay triggers use the `render` prop to style themselves: `}>Open`. - Themes: `nook add theme `. Presets: cobalt, moss, tide, lagoon, dusk, blossom, honey, graphite. Build codes at http://localhost:3000/themes. ## CLI - `nook init [--css ]`: set up the project. - `nook add `: add components. Also `nook add theme `, `nook add icon `, `@namespace/item` and direct URLs. - `nook list [--type ]`: list registry items. - Options: `--yes`, `--overwrite`, `--cwd `, `--dry-run`, `--no-install`, `--registry `. Files are never overwritten without asking. ## Button Triggers an action. Comes with variants, sizes and a loading state, and exports its styles for links. Install: `npx nook-ui@latest add button` Accessibility: Renders a native button with type=button by default. While `loading`, the button sets `aria-busy`, ignores presses and keeps keyboard focus. To make a link look like a button, put `buttonVariants()` on the anchor. Variant `variant`: default, secondary, outline, ghost, destructive, link (default default) Variant `size`: sm, md, lg, icon (default md) ### Button: Button The button element. - `loading` (`boolean`, default false): Shows the loader and ignores presses. - `...props` (`React.ButtonHTMLAttributes`): Everything the native element accepts, such as `id`, `aria-*` and event handlers. Example: ```tsx import { Button } from "@/components/ui/button"; export default function ButtonVariants() { return (
); } ``` ## Input A single line text field with invalid, disabled and focus states, plus a group for icons and add-ons. Install: `npx nook-ui@latest add input` Accessibility: Always pair with a Label (`htmlFor`) or `aria-label`. Set `aria-invalid` and link the error with `aria-describedby`. ### Input: Input The input element. - `type` (`string`, default "text"): Any valid input type. - `size` (`"sm" | "md" | "lg"`, default "md"): Height, following the density token like Button. - `...props` (`React.InputHTMLAttributes`): Everything the native element accepts, such as `id`, `aria-*` and event handlers. ### Input: InputGroup Wraps an Input and its add-ons in one field. - `size` (`"sm" | "md" | "lg"`, default "md"): Height of the whole field. - `...props` (`React.HTMLAttributes`): Everything the native element accepts, such as `id`, `aria-*` and event handlers. ### Input: InputAddon An icon, a prefix or a small button inside the group. - `...props` (`React.HTMLAttributes`): Everything the native element accepts, such as `id`, `aria-*` and event handlers. Example: ```tsx import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; export default function InputDefault() { return (
); } ``` ## Textarea A multi-line text field. Install: `npx nook-ui@latest add textarea` Accessibility: Always pair with a Label or `aria-label`. Variant `size`: sm, md, lg (default md) ### Textarea: Textarea The textarea element. - `size` (`"sm" | "md" | "lg"`, default "md"): Least height, padding and text size. - `...props` (`React.TextareaHTMLAttributes`): Everything the native element accepts, such as `id`, `aria-*` and event handlers. Example: ```tsx import { Label } from "@/components/ui/label"; import { Textarea } from "@/components/ui/textarea"; export default function TextareaDefault() { return (