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
Syncing files
Saving draft
Preparing the preview
Field notes.pdf
Your research, all in one place.
;
}
```
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`): 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.