Add the Nook "Dropdown Menu" component to this project, exactly as Nook ships it.
A menu of actions opened from a button, with checkbox and radio items.
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 dropdown-menu`. It writes `components/ui/dropdown-menu.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/dropdown-menu.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 {
DropdownMenu,
DropdownMenuCheckboxItem,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
export default function DropdownMenuDefault() {
const [showTips, setShowTips] = React.useState(true);
const [sort, setSort] = React.useState("newest");
return (
}>Options
My accountProfileBilling
Show tips
Newest firstOldest firstSign out
);
}
```
API
- `DropdownMenu`: Owns the open state.
- `open` (`boolean`): Controlled open state.
- `onOpenChange` (`(open: boolean) => void`): Called when it opens or closes.
- `DropdownMenuTrigger`: The button that opens the menu. Use `render={}`.
- `DropdownMenuContent`: The popup.
- `side` (`"top" | "right" | "bottom" | "left"`, default "bottom"): Preferred side.
- `align` (`"start" | "center" | "end"`, default "start"): Alignment against the trigger.
- `sideOffset` (`number`, default 6): Gap in pixels.
- `DropdownMenuItem`: An action.
- `onClick` (`MouseEventHandler`): Runs when chosen.
- `destructive` (`boolean`, default false): Marks the action as destructive without relying on color alone.
- `closeOnClick` (`boolean`, default true): Close the menu after choosing.
- `disabled` (`boolean`, default false): Disables the item.
- `DropdownMenuCheckboxItem`: A toggleable item.
- `checked` (`boolean`): Controlled state.
- `onCheckedChange` (`(checked: boolean) => void`): Called when toggled.
- `DropdownMenuRadioGroup / DropdownMenuRadioItem`: Pick one item from a set.
- `value` (`string`): Selected value (group).
- `onValueChange` (`(value: string) => void`): Called on change (group).
- `DropdownMenuGroup / DropdownMenuLabel / DropdownMenuSeparator`: Structure the menu.
- `DropdownMenuSub / DropdownMenuSubTrigger / DropdownMenuSubContent`: A nested menu. The trigger is an item with a chevron; the content opens to the right.
- `DropdownMenuShortcut`: Keys shown at the end of an item, for example ⌘K. Display only.
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: Arrow keys move, Enter or Space activates, typeahead jumps, Escape closes and returns focus to the trigger.
Done when the component renders like the example in light and dark mode and the project type-checks.