Add the Nook "Toast" component to this project, exactly as Nook ships it.
Brief messages shown from anywhere with a function call. Mount the Toaster once.
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 toast`. It writes `components/ui/toast.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/toast.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 { Button } from "@/components/ui/button";
import { Toaster, toast } from "@/components/ui/toast";
export default function ToastDefault() {
return (
);
}
```
API
- `Toaster`: Mount once near the root of your app.
- `position` (`"top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right"`, default "bottom-right"): Where toasts stack.
- `timeout` (`number`, default 5000): Default milliseconds before a toast closes.
- `className` (`string`): Classes for the viewport.
- `toast(options)`: Show a toast. Returns its id.
- `title` (`ReactNode`): Short heading.
- `description` (`ReactNode`): Supporting text.
- `variant` (`"default" | "success" | "info" | "warning" | "destructive" | "loading"`, default "default"): Icon and announcement priority. A warning has a dashed edge and an alert mark, not a color.
- `action` (`{ label: string; onClick: () => void }`): A button in the toast, such as Undo. The toast closes when it is pressed.
- `timeout` (`number`): Override the default. Use 0 to keep it until dismissed.
- `toastPromise(promise, messages)`: One toast that shows a loader while the promise runs, then the result. Returns the promise.
- `loading` (`ToastOptions`): Shown while the promise is pending.
- `success` (`ToastOptions | (value) => ToastOptions`): Shown when it resolves.
- `error` (`ToastOptions | (reason) => ToastOptions`): Shown when it rejects.
- `dismissToast(id?)`: Close one toast, or all when no id is given.
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: Toasts live in a polite live region. Destructive toasts are high priority. Press F6 to jump to the region; do not use toasts for information that must not be missed.
Done when the component renders like the example in light and dark mode and the project type-checks.