npx shadcn@4.23.1 add @goop/trail-menu-buttonMenu button
FreeThe button a menu opens from, shown as words, a workspace's tile or an icon, for React and Tailwind CSS. Free, MIT.
import { MenuButton, MenuButtonAvatar, MenuButtonLabel, MenuButtonIcon } from '@/components/ui/goop/menu-button';
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from '@/components/ui/goop/dropdown-menu';
<DropdownMenu>
<DropdownMenuTrigger asChild>
<MenuButton>
<MenuButtonLabel>Workspace</MenuButtonLabel>
</MenuButton>
</DropdownMenuTrigger>
<DropdownMenuContent aria-label="Workspace">
<DropdownMenuItem>Workspace settings</DropdownMenuItem>
<DropdownMenuItem>Log out</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>Open a menu button by click, Enter or the down arrow. In the workspace look switch to another workspace (the button and the page under it follow), or sign out and in again; Look also shows a view’s heading, the tools pill (turn tools on and off), the help disc and the ellipsis of more actions at two sizes. The workspaces, the sign-in and every row are our own sample: nothing is signed out of, and a picked row is only written down.
When to use
- The button a menu opens from, shown as words, a workspace's tile or an icon.
- Also called: dropdown button.
When not to use
- Use it as the trigger of a DropdownMenu.
Installation
Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Menu button on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing.
npx shadcn@4.23.1 add @goop/trail-menu-buttonAdd the Goop Menu button to this project. The install steps are at https://goop.so/docs/install.mdUsage
import { MenuButton, MenuButtonAvatar, MenuButtonLabel, MenuButtonIcon } from '@/components/ui/goop/menu-button';
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from '@/components/ui/goop/dropdown-menu';
<DropdownMenu>
<DropdownMenuTrigger asChild>
<MenuButton>
<MenuButtonLabel>Workspace</MenuButtonLabel>
</MenuButton>
</DropdownMenuTrigger>
<DropdownMenuContent aria-label="Workspace">
<DropdownMenuItem>Workspace settings</DropdownMenuItem>
<DropdownMenuItem>Log out</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>- Fits: list, record: toolbar.
- height, width, padding, gap, corner, border, background, shadow, text, motion: add no class for these.
API reference
| Option | Type | What it does |
|---|---|---|
| shape | rounded | pill | circle | icon = pill | |
| size | sm | md | lg = md | |
| aria-label? | string | The button's name for assistive technology: required on the help disc and the icon shape, which hold no words. |
| asChild? | boolean = false | |
| type? | 'button' | 'submit' | 'reset' | |
| onClick? | (event: MouseEvent) => void | |
| disabled? | boolean |
| Part | What it is |
|---|---|
| MenuButtonAvatar | The workspace's (or a person's) tile; also takes name?: string; hue?: AvatarHue; fill?: string; status?: 'online' | 'away' | 'busy' | 'offline'; statusLabel?: string |
| MenuButtonLabel | The button's words where they carry their own type |
| MenuButtonIcon | An icon before the words; className?: string — Classes added to the glyph's holder; its box and ink are already set; icon: IconName — A pack icon name |
- Class recipes (cva): menuButtonVariants (MenuButton)
- data-slot values (to select a part by): menu-button, menu-button-icon, menu-button-indicator, menu-button-label
Keyboard
| Key | What it does |
|---|---|
| Enter | Open the menu |
| ArrowDown | Open the menu |
Accessibility
- The native element answers the keyboard.
- hover, active, focus, focus-visible: the browser's own (:hover, :active, :focus, :focus-visible): write nothing
Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:
| State | Drawn by |
|---|---|
| expanded | the attribute data-state=open |
| open | the attribute data-state=open |
| disabled | the prop disabled |
Motion
- The part sets its own motion: add no transition or animation of your own.
- How the theme moves, and how to move your own parts the same way: Motion.
Notes for AI
Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.