nook
Browse the docs

Components

Confetti

Native

Small squares thrown from the middle for a moment worth marking.

See the prompt

Finish the plan to celebrate.

Installation

npx nook-ui@latest add confetti

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

Small squares thrown from the middle for a moment worth marking.

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 confetti`. It writes `components/ui/confetti.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/confetti.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 { Button } from "@/components/ui/button";
import { Confetti } from "@/components/ui/confetti";

export default function ConfettiDefault() {
  const [burst, setBurst] = React.useState(0);
  return (
    <div className="relative grid min-h-48 w-full place-content-center justify-items-center gap-3 overflow-hidden text-center">
      <Confetti burst={burst} />
      <p role="status" className="text-lg font-semibold">{burst ? "You finished your first plan." : "Finish the plan to celebrate."}</p>
      <Button onClick={() => setBurst((n) => n + 1)}>Finish the plan</Button>
    </div>
  );
}
```

API
- `Confetti`: Put it inside a relatively positioned element.
  - `burst` (`number`): Change it to fire another burst. 0 fires none.
  - `pieces` (`number`): How many pieces. Default 36.

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: Decoration only and hidden from assistive tech. It draws nothing when motion is reduced, so always say the news in words too.

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 { Button } from "@/components/ui/button";
import { Confetti } from "@/components/ui/confetti";

export default function ConfettiDefault() {
  const [burst, setBurst] = React.useState(0);
  return (
    <div className="relative grid min-h-48 w-full place-content-center justify-items-center gap-3 overflow-hidden text-center">
      <Confetti burst={burst} />
      <p role="status" className="text-lg font-semibold">{burst ? "You finished your first plan." : "Finish the plan to celebrate."}</p>
      <Button onClick={() => setBurst((n) => n + 1)}>Finish the plan</Button>
    </div>
  );
}

Examples

Small burst

Big burst

Ready to launch?

Props

Confetti

Put it inside a relatively positioned element.

PropTypeDefaultDescription
burstnumber–Change it to fire another burst. 0 fires none.
piecesnumber–How many pieces. Default 36.

Accessibility

Decoration only and hidden from assistive tech. It draws nothing when motion is reduced, so always say the news in words too.

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