Components
Loading
NativeSquare-dot spinners, dots, a bar, character frames, overlays and full-area loading states.
Preparing the preview
Field notes.pdf
Your research, all in one place.
Opening your studio…
Installation
npx nook-ui@latest add loadingPrompt
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.
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
Dots and bar
Props
Loading / Spinner
The existing square-dot LoaderIcon, at three sizes.
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | Loading | The screen reader announcement. |
| size | "sm" | "md" | "lg" | 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.
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | Loading | What is in progress. |
AsciiLoader
A monospace frame sequence and a visible label. Frame timing follows the theme motion token.
| Prop | Type | Default | Description |
|---|---|---|---|
| frames | readonly string[] | – | Custom character frames. Empty arrays have a static fallback. |
| label | string | Working | The visible status. |
LoadingOverlay
Covers a positioned parent with a loader and label.
| Prop | Type | Default | Description |
|---|---|---|---|
| active | boolean | true | Show the overlay and mark its parent busy. |
| label | string | 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.
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | 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.
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.