nook
Browse the docs

Components

Loading

Native

Square-dot spinners, dots, a bar, character frames, overlays and full-area loading states.

See the prompt
Syncing files
Syncing files
Saving draft
Saving draft

Preparing the preview

Preparing the preview
Building your workspace

Field notes.pdf

Your research, all in one place.

Uploading field notes…

Opening your studio…

Installation

npx nook-ui@latest add loading

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

Square-dot spinners, dots, a bar, character frames, overlays and full-area loading states.

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 loading`. It writes `components/ui/loading.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/loading.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
"use client";

import * as React from "react";
import { AsciiLoader, LoadingBar, LoadingDots, LoadingOverlay, LoadingScreen, Spinner } from "@/components/ui/loading";
import { Button } from "@/components/ui/button";

export default function LoadingDefault() {
  const [busy, setBusy] = React.useState(true);
  return <div className="grid w-full gap-6">
    <div className="grid grid-cols-2 gap-6"><div className="flex items-center gap-3"><Spinner size="sm" label="Syncing files" /><span className="text-sm">Syncing files</span></div><div className="flex items-center gap-3"><LoadingDots label="Saving draft" /><span className="text-sm">Saving draft</span></div></div>
    <div className="grid gap-2"><p className="text-xs text-muted-foreground">Preparing the preview</p><LoadingBar label="Preparing the preview" /></div>
    <AsciiLoader label="Building your workspace" />
    <div className="relative min-h-40 rounded-lg border-(length:--edge) border-(--surface-edge) bg-muted/30 p-5"><p className="font-medium">Field notes.pdf</p><p className="mt-2 text-sm text-muted-foreground">Your research, all in one place.</p><LoadingOverlay active={busy} label="Uploading field notes…" /></div>
    <Button variant="outline" size="sm" className="justify-self-start" onClick={() => setBusy((value) => !value)}>{busy ? "Finish upload" : "Upload again"}</Button>
    <LoadingScreen label="Opening your studio…" className="min-h-40 rounded-lg border-(length:--edge) border-(--surface-edge)" />
  </div>;
}
```

API
- `Loading / Spinner`: The existing square-dot LoaderIcon, at three sizes.
  - `label` (`string`, default Loading): The screen reader announcement.
  - `size` (`"sm" | "md" | "lg"`, default md): Icon size.
  - `...props` (`React.HTMLAttributes<HTMLDivElement>`): Everything the native element accepts, such as `id`, `aria-*` and event handlers.
- `LoadingDots / LoadingBar`: Three square dots, or an indeterminate bar. Both retain a screen reader label while static.
  - `label` (`string`, default Loading): What is in progress.
- `AsciiLoader`: A monospace frame sequence and a visible label. Frame timing follows the theme motion token.
  - `frames` (`readonly string[]`): Custom character frames. Empty arrays have a static fallback.
  - `label` (`string`, default Working): The visible status.
- `LoadingOverlay`: Covers a positioned parent with a loader and label.
  - `active` (`boolean`, default true): Show the overlay and mark its parent busy.
  - `label` (`string`, default Loading): Visible status text.
  - `children` (`ReactNode`): Replace the default loader.
- `LoadingScreen`: A centered loader filling its region. Set a minimum height for a full-screen view.
  - `label` (`string`, default Getting things ready): The visible message.
- `useReducedMotion`: A shared hook for visual components. Starts true for server rendering, then follows the user's media preference.

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 loader has a text label and role=status. Motion stops with reduced motion; ASCII shows its first frame. LoadingOverlay sets aria-busy on its parent and restores the previous value when it ends. useReducedMotion follows preference changes after mount.

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

Usage

"use client";

import * as React from "react";
import { AsciiLoader, LoadingBar, LoadingDots, LoadingOverlay, LoadingScreen, Spinner } from "@/components/ui/loading";
import { Button } from "@/components/ui/button";

export default function LoadingDefault() {
  const [busy, setBusy] = React.useState(true);
  return <div className="grid w-full gap-6">
    <div className="grid grid-cols-2 gap-6"><div className="flex items-center gap-3"><Spinner size="sm" label="Syncing files" /><span className="text-sm">Syncing files</span></div><div className="flex items-center gap-3"><LoadingDots label="Saving draft" /><span className="text-sm">Saving draft</span></div></div>
    <div className="grid gap-2"><p className="text-xs text-muted-foreground">Preparing the preview</p><LoadingBar label="Preparing the preview" /></div>
    <AsciiLoader label="Building your workspace" />
    <div className="relative min-h-40 rounded-lg border-(length:--edge) border-(--surface-edge) bg-muted/30 p-5"><p className="font-medium">Field notes.pdf</p><p className="mt-2 text-sm text-muted-foreground">Your research, all in one place.</p><LoadingOverlay active={busy} label="Uploading field notes…" /></div>
    <Button variant="outline" size="sm" className="justify-self-start" onClick={() => setBusy((value) => !value)}>{busy ? "Finish upload" : "Upload again"}</Button>
    <LoadingScreen label="Opening your studio…" className="min-h-40 rounded-lg border-(length:--edge) border-(--surface-edge)" />
  </div>;
}

Examples

Spinner sizes

Loading, sm
sm
Loading, md
md
Loading, lg
lg

Dots and bar

Maya is typing
Maya is typing
Importing 1,240 contacts
Importing contacts

Props

Loading / Spinner

The existing square-dot LoaderIcon, at three sizes.

PropTypeDefaultDescription
labelstringLoadingThe screen reader announcement.
size"sm" | "md" | "lg"mdIcon size.
...propsReact.HTMLAttributes<HTMLDivElement>–Everything the native element accepts, such as `id`, `aria-*` and event handlers.

LoadingDots / LoadingBar

Three square dots, or an indeterminate bar. Both retain a screen reader label while static.

PropTypeDefaultDescription
labelstringLoadingWhat is in progress.

AsciiLoader

A monospace frame sequence and a visible label. Frame timing follows the theme motion token.

PropTypeDefaultDescription
framesreadonly string[]–Custom character frames. Empty arrays have a static fallback.
labelstringWorkingThe visible status.

LoadingOverlay

Covers a positioned parent with a loader and label.

PropTypeDefaultDescription
activebooleantrueShow the overlay and mark its parent busy.
labelstringLoadingVisible status text.
childrenReactNode–Replace the default loader.

LoadingScreen

A centered loader filling its region. Set a minimum height for a full-screen view.

PropTypeDefaultDescription
labelstringGetting things readyThe visible message.

useReducedMotion

A shared hook for visual components. Starts true for server rendering, then follows the user's media preference.

Accessibility

Every loader has a text label and role=status. Motion stops with reduced motion; ASCII shows its first frame. LoadingOverlay sets aria-busy on its parent and restores the previous value when it ends. useReducedMotion follows preference changes after mount.

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