nook
Browse the docs

Components

Flow

Native

A canvas of nodes joined by lines, for flows and site maps.

See the prompt
Visitor arrives
Page Sign up
Email Verify email
Page Choose a plan
Page Dashboard
Tasks
Reports
Settings

Installation

npx nook-ui@latest add flow

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 "Flow" component to this project, exactly as Nook ships it.

A canvas of nodes joined by lines, for flows and site maps.

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 flow`. It writes `components/ui/flow.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/flow.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 { CheckIcon, FileIcon, MailIcon, SearchIcon } from "@/components/icons";
import { Flow } from "@/components/ui/flow";

export default function FlowDefault() {
  return (
    <Flow
      title="Sign-up flow"
      className="h-[26rem]"
      defaultNodes={[
        { id: "start", x: 24, y: 24, label: "Visitor arrives", tone: "brand", width: 152, height: 40 },
        { id: "signup", x: 24, y: 112, label: "Sign up", caption: "Page", icon: <FileIcon /> },
        { id: "verify", x: 264, y: 112, label: "Verify email", caption: "Email", icon: <MailIcon /> },
        { id: "plan", x: 504, y: 112, label: "Choose a plan", caption: "Page", icon: <SearchIcon /> },
        { id: "home", x: 504, y: 232, label: "Dashboard", caption: "Page", icon: <CheckIcon /> },
        { id: "tasks", x: 360, y: 344, label: "Tasks", tone: "muted" },
        { id: "reports", x: 520, y: 344, label: "Reports", tone: "muted" },
        { id: "settings", x: 680, y: 344, label: "Settings", tone: "muted" },
      ]}
      edges={[
        { from: "start", to: "signup" },
        { from: "signup", to: "verify" },
        { from: "verify", to: "plan" },
        { from: "plan", to: "home" },
        { from: "home", to: "tasks", dashed: true },
        { from: "home", to: "reports", dashed: true },
        { from: "home", to: "settings", dashed: true },
      ]}
    />
  );
}
```

API
- `Flow`: The canvas. Lines are drawn for you, right-angled, between the sides that face each other.
  - `title` (`string`): What the diagram shows.
  - `defaultNodes / nodes` (`{ id; x; y; label; caption?; icon?; tone?; width?; height? }[]`): The nodes and where they sit.
  - `edges` (`{ from; to; dashed? }[]`): The lines, by node id.
  - `onNodesChange` (`(nodes) => void`): Called when a node is moved.
  - `readOnly` (`boolean`): Nodes cannot be moved.

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: Every node can be focused and says what it leads to. Arrow keys move the focused node by one grid step, with Shift by five. Dragging and zooming are also available as buttons.

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

Usage

import { CheckIcon, FileIcon, MailIcon, SearchIcon } from "@/components/icons";
import { Flow } from "@/components/ui/flow";

export default function FlowDefault() {
  return (
    <Flow
      title="Sign-up flow"
      className="h-[26rem]"
      defaultNodes={[
        { id: "start", x: 24, y: 24, label: "Visitor arrives", tone: "brand", width: 152, height: 40 },
        { id: "signup", x: 24, y: 112, label: "Sign up", caption: "Page", icon: <FileIcon /> },
        { id: "verify", x: 264, y: 112, label: "Verify email", caption: "Email", icon: <MailIcon /> },
        { id: "plan", x: 504, y: 112, label: "Choose a plan", caption: "Page", icon: <SearchIcon /> },
        { id: "home", x: 504, y: 232, label: "Dashboard", caption: "Page", icon: <CheckIcon /> },
        { id: "tasks", x: 360, y: 344, label: "Tasks", tone: "muted" },
        { id: "reports", x: 520, y: 344, label: "Reports", tone: "muted" },
        { id: "settings", x: 680, y: 344, label: "Settings", tone: "muted" },
      ]}
      edges={[
        { from: "start", to: "signup" },
        { from: "signup", to: "verify" },
        { from: "verify", to: "plan" },
        { from: "plan", to: "home" },
        { from: "home", to: "tasks", dashed: true },
        { from: "home", to: "reports", dashed: true },
        { from: "home", to: "settings", dashed: true },
      ]}
    />
  );
}

Examples

A workflow run

Each step shows where the run is, in a mark and in words.

Trigger Order received
Step Check stock
Step Charge card
Email Send receipt
On failure Alert support

Props

Flow

The canvas. Lines are drawn for you, right-angled, between the sides that face each other.

PropTypeDefaultDescription
titlestring–What the diagram shows.
defaultNodes / nodes{ id; x; y; label; caption?; icon?; tone?; width?; height? }[]–The nodes and where they sit.
edges{ from; to; dashed? }[]–The lines, by node id.
onNodesChange(nodes) => void–Called when a node is moved.
readOnlyboolean–Nodes cannot be moved.

Accessibility

Every node can be focused and says what it leads to. Arrow keys move the focused node by one grid step, with Shift by five. Dragging and zooming are also available as buttons.

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