Appearance
Menu
The Menu component provides a dropdown menu with a compound component API. It is backed by Base UI's Menu primitive.
Import
tsx
import { Menu } from "@tailor-platform/app-shell";The runnable examples also import useState from react, Button and Text from @tailor-platform/app-shell, and EllipsisVerticalIcon from lucide-react.
Basic Usage
tsx
function BasicUsage() {
return (
<Menu.Root>
<Menu.Trigger>Open menu</Menu.Trigger>
<Menu.Content>
<Menu.Item>Edit</Menu.Item>
<Menu.Item>Duplicate</Menu.Item>
<Menu.Separator />
<Menu.Item>Delete</Menu.Item>
</Menu.Content>
</Menu.Root>
);
}Sub-components
| Sub-component | Description |
|---|---|
Menu.Root | Manages menu open/close state |
Menu.Trigger | Element that opens the menu when clicked |
Menu.Content | The menu popup containing menu items |
Menu.Item | An individual interactive item |
Menu.LinkItem | A link item for navigation |
Menu.CheckboxItem | A menu item that toggles a setting on or off |
Menu.CheckboxItemIndicator | Indicates whether the checkbox item is ticked |
Menu.RadioItem | A menu item that works like a radio button within a group |
Menu.RadioItemIndicator | Indicates whether the radio item is selected |
Menu.RadioGroup | Groups related radio items |
Menu.Group | Groups related menu items |
Menu.GroupLabel | An accessible label for a Menu.Group |
Menu.Separator | A visual separator between menu items |
Menu.SubmenuRoot | Groups all parts of a nested sub-menu |
Menu.SubmenuTrigger | A menu item that opens a sub-menu |
Props
Menu.Root Props
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | - | Controlled open state |
defaultOpen | boolean | false | Initial open state (uncontrolled) |
onOpenChange | (open: boolean) => void | - | Callback when open state changes |
modal | boolean | true | Whether the menu is modal |
disabled | boolean | false | Disables the entire menu |
children | React.ReactNode | - | Menu sub-components |
Menu.Content Props
| Prop | Type | Default | Description |
|---|---|---|---|
position | { side?: "top" | "right" | "bottom" | "left"; align?: "start" | "center" | "end"; sideOffset?: number } | { side: "bottom", align: "start", sideOffset: 4 } | Placement of the popup |
className | string | - | Additional CSS classes |
children | React.ReactNode | - | Menu items and other sub-components |
Menu.Item Props
Accepts className, disabled, and all standard Base UI Menu.Item props.
Menu.SubmenuRoot Props
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | - | Controlled open state |
defaultOpen | boolean | false | Initial open state (uncontrolled) |
onOpenChange | (open: boolean) => void | - | Callback when open state changes |
disabled | boolean | false | Disables the entire sub-menu |
children | React.ReactNode | - | Sub-menu sub-components |
Grouped Items
Use Menu.Group and Menu.GroupLabel to visually group related items:
tsx
function GroupedItems() {
return (
<Menu.Root>
<Menu.Trigger>Actions</Menu.Trigger>
<Menu.Content>
<Menu.Group>
<Menu.GroupLabel>File</Menu.GroupLabel>
<Menu.Item>New</Menu.Item>
<Menu.Item>Open</Menu.Item>
</Menu.Group>
<Menu.Separator />
<Menu.Group>
<Menu.GroupLabel>Edit</Menu.GroupLabel>
<Menu.Item>Cut</Menu.Item>
<Menu.Item>Copy</Menu.Item>
<Menu.Item>Paste</Menu.Item>
</Menu.Group>
</Menu.Content>
</Menu.Root>
);
}Checkbox Items
Open Format text and toggle Bold or Italic. The sample text and the reported settings update together.
tsx
function CheckboxItems() {
const [bold, setBold] = useState(false);
const [italic, setItalic] = useState(false);
return (
<div className="space-y-3">
<Menu.Root>
<Menu.Trigger render={<Button variant="outline" />}>Format text</Menu.Trigger>
<Menu.Content>
<Menu.CheckboxItem checked={bold} onCheckedChange={setBold}>
<Menu.CheckboxItemIndicator>✓</Menu.CheckboxItemIndicator>
Bold
</Menu.CheckboxItem>
<Menu.CheckboxItem checked={italic} onCheckedChange={setItalic}>
<Menu.CheckboxItemIndicator>✓</Menu.CheckboxItemIndicator>
Italic
</Menu.CheckboxItem>
</Menu.Content>
</Menu.Root>
<Text.p
style={{ fontWeight: bold ? "bold" : "normal", fontStyle: italic ? "italic" : "normal" }}
>
Format this sample text.
</Text.p>
<Text.p role="status">
Bold: {bold ? "on" : "off"}; italic: {italic ? "on" : "off"}
</Text.p>
</div>
);
}Radio Items
Choose an alignment from Align text. Only one radio item is selected, and the sample text moves to that alignment.
tsx
function RadioItems() {
const [align, setAlign] = useState("left");
return (
<div className="space-y-3">
<Menu.Root>
<Menu.Trigger render={<Button variant="outline" />}>Align text</Menu.Trigger>
<Menu.Content>
<Menu.RadioGroup value={align} onValueChange={setAlign}>
{["left", "center", "right"].map((value) => (
<Menu.RadioItem key={value} value={value}>
<Menu.RadioItemIndicator>●</Menu.RadioItemIndicator>
{value}
</Menu.RadioItem>
))}
</Menu.RadioGroup>
</Menu.Content>
</Menu.Root>
<Text.p
className={
align === "center" ? "text-center" : align === "right" ? "text-right" : "text-left"
}
>
Align this sample text.
</Text.p>
<Text.p role="status">Alignment: {align}</Text.p>
</div>
);
}Nested Sub-menus
tsx
function NestedSubmenus() {
return (
<Menu.Root>
<Menu.Trigger>Edit</Menu.Trigger>
<Menu.Content>
<Menu.Item>Cut</Menu.Item>
<Menu.Item>Copy</Menu.Item>
<Menu.SubmenuRoot>
<Menu.SubmenuTrigger>Paste Special ›</Menu.SubmenuTrigger>
<Menu.Content>
<Menu.Item>Paste as Plain Text</Menu.Item>
<Menu.Item>Paste and Match Style</Menu.Item>
</Menu.Content>
</Menu.SubmenuRoot>
</Menu.Content>
</Menu.Root>
);
}Examples
Row Actions Menu
Open the order's three-dot button and choose an action. This is a button-triggered dropdown, not a right-click context menu. The example records the chosen action locally without modifying an order or navigating away. Use render to make the styled Button the trigger itself, rather than nesting two buttons.
tsx
function RowActions() {
const orderNumber = "ORD-1001";
const [lastAction, setLastAction] = useState("None");
return (
<div className="space-y-3">
<div className="flex items-center gap-3">
<Text.span>{orderNumber}</Text.span>
<Menu.Root>
<Menu.Trigger render={<Button variant="ghost" size="icon" aria-label="Order actions" />}>
<EllipsisVerticalIcon />
</Menu.Trigger>
<Menu.Content>
<Menu.Item onClick={() => setLastAction(`Edit ${orderNumber}`)}>Edit</Menu.Item>
<Menu.Item onClick={() => setLastAction(`Duplicate ${orderNumber}`)}>
Duplicate
</Menu.Item>
<Menu.Separator />
<Menu.Item onClick={() => setLastAction(`View history for ${orderNumber}`)}>
View history
</Menu.Item>
</Menu.Content>
</Menu.Root>
</div>
<Text.p role="status">Last action: {lastAction}</Text.p>
</div>
);
}Accessibility
- Menu items are keyboard navigable with arrow keys
- Pressing
Escapecloses the menu - Sub-menus open on arrow-right and close on arrow-left
Menu.GroupLabelis automatically associated with its parent group