nook
Browse the docs

Components

Background

Native

A backdrop behind content: dots, grid, halftone, grain, gradient, mesh or aurora.

See the prompt
  • dots
  • grid
  • halftone
  • noise
  • gradient
  • mesh
  • aurora

Installation

npx nook-ui@latest add background

Prompt

Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.

Short. For assistants that can run commands in your project.

Plain text
Add the Nook "Background" component to this project, exactly as Nook ships it.

A backdrop behind content: dots, grid, halftone, grain, gradient, mesh or aurora.

Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add background`. It writes `components/ui/background.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/background.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:

```tsx
import { Background, type BackgroundVariant } from "@/components/ui/background";

const VARIANTS: BackgroundVariant[] = ["dots", "grid", "halftone", "noise", "gradient", "mesh", "aurora"];

export default function BackgroundDefault() {
  return (
    <ul className="grid w-full gap-4 sm:grid-cols-2 lg:grid-cols-3">
      {VARIANTS.map((variant) => (
        <li key={variant}><Background variant={variant} className="grid h-36 place-content-center rounded-lg border-(length:--edge) border-(--surface-edge) bg-card"><span className="font-medium capitalize">{variant}</span></Background></li>
      ))}
    </ul>
  );
}
```

API
- `Background`: Wraps the content it sits behind.
  - `variant` (`dots | grid | halftone | noise | gradient | mesh | aurora`): Which pattern.
  - `fade` (`boolean`): Fade toward the edges so text stays readable. Default true.

Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: Pure decoration, hidden from assistive tech. Colors come from the theme tokens, so it follows light and dark. The aurora is still under reduced motion.

Done when the component renders like the example in light and dark mode and the project type-checks.

Usage

import { Background, type BackgroundVariant } from "@/components/ui/background";

const VARIANTS: BackgroundVariant[] = ["dots", "grid", "halftone", "noise", "gradient", "mesh", "aurora"];

export default function BackgroundDefault() {
  return (
    <ul className="grid w-full gap-4 sm:grid-cols-2 lg:grid-cols-3">
      {VARIANTS.map((variant) => (
        <li key={variant}><Background variant={variant} className="grid h-36 place-content-center rounded-lg border-(length:--edge) border-(--surface-edge) bg-card"><span className="font-medium capitalize">{variant}</span></Background></li>
      ))}
    </ul>
  );
}

Examples

Behind a hero

Plans that stay true

Move a task and every view updates with it.

With and without fade

Without fade
With fade

Props

Background

Wraps the content it sits behind.

PropTypeDefaultDescription
variantdots | grid | halftone | noise | gradient | mesh | aurora–Which pattern.
fadeboolean–Fade toward the edges so text stays readable. Default true.

Accessibility

Pure decoration, hidden from assistive tech. Colors come from the theme tokens, so it follows light and dark. The aurora is still under reduced motion.

Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.