@usevyre/react@usevyre/vue

Dropdown Menu

A contextual action menu anchored to a trigger. Supports icons, keyboard shortcuts, labels, separators, submenus, checkbox items, radio groups, and full keyboard navigation (Arrow keys, Home, End, Escape).


Basic with submenu

Compose DropdownItem, DropdownLabel, DropdownSeparator, and DropdownSub inside DropdownMenu. Hover "Share" to open the nested submenu.

import {
  DropdownMenu, DropdownItem, DropdownSeparator,
  DropdownLabel, DropdownSub, Button,
} from "@usevyre/react";

<DropdownMenu trigger={<Button variant="secondary">Actions</Button>}>
  <DropdownLabel>File</DropdownLabel>
  <DropdownItem icon={<EditIcon />} shortcut="⌘E" onSelect={handleEdit}>Edit</DropdownItem>
  <DropdownItem icon={<CopyIcon />} shortcut="⌘D" onSelect={handleDuplicate}>Duplicate</DropdownItem>
  <DropdownSub trigger="Share" icon={<ShareIcon />}>
    <DropdownItem onSelect={handleEmail}>Email</DropdownItem>
    <DropdownItem onSelect={handleLink}>Copy link</DropdownItem>
  </DropdownSub>
  <DropdownSeparator />
  <DropdownItem variant="danger" icon={<TrashIcon />} onSelect={handleDelete}>Delete</DropdownItem>
</DropdownMenu>

Checkbox items

Use DropdownCheckboxItem for toggle options that don't close the menu after selection.

import { DropdownMenu, DropdownCheckboxItem, DropdownLabel, DropdownSeparator } from "@usevyre/react";

const [showToolbar, setShowToolbar] = useState(true);
const [showPanel,   setShowPanel]   = useState(false);

<DropdownMenu trigger={<Button variant="secondary">View</Button>}>
  <DropdownLabel>Toggle panels</DropdownLabel>
  <DropdownSeparator />
  <DropdownCheckboxItem checked={showToolbar} onCheckedChange={setShowToolbar}>
    Toolbar
  </DropdownCheckboxItem>
  <DropdownCheckboxItem checked={showPanel} onCheckedChange={setShowPanel}>
    Side Panel
  </DropdownCheckboxItem>
</DropdownMenu>

Radio group

Wrap DropdownRadioItem inside DropdownRadioGroup for exclusive single-selection options.

import { DropdownMenu, DropdownRadioGroup, DropdownRadioItem, DropdownLabel } from "@usevyre/react";

const [theme, setTheme] = useState("system");

<DropdownMenu trigger={<Button variant="secondary">Theme: {theme}</Button>}>
  <DropdownLabel>Appearance</DropdownLabel>
  <DropdownRadioGroup value={theme} onValueChange={setTheme}>
    <DropdownRadioItem value="light">Light</DropdownRadioItem>
    <DropdownRadioItem value="dark">Dark</DropdownRadioItem>
    <DropdownRadioItem value="system">System</DropdownRadioItem>
  </DropdownRadioGroup>
</DropdownMenu>

Placement

bottom-start aligns the menu's left edge to the trigger's left edge.bottom-end aligns to the right edge (useful for menus inside right-aligned toolbars).

<DropdownMenu placement="bottom-start" trigger={<Button>bottom-start</Button>}>...</DropdownMenu>
<DropdownMenu placement="bottom-end"  trigger={<Button>bottom-end</Button>}>...</DropdownMenu>

DropdownMenu props

Props

PropTypeDefaultDescription
triggerReactElement(React) The trigger button. Passed as a prop.
#trigger slotslot(Vue) The trigger button. Use the named slot.
placement"bottom-start" | "bottom-end" | "top-start" | "top-end""bottom-start"Position relative to the trigger.
class / classNamestringAdditional CSS class on the menu panel.

DropdownItem props

Props

PropTypeDefaultDescription
onSelect / @select() => voidCalled when item is clicked. Menu closes automatically.
disabledbooleanfalsePrevents selection and dims the item.
variant"default" | "danger""default"Danger variant renders the item in red.
iconReactNode / #icon slotIcon displayed to the left of the label.
shortcutstringKeyboard hint displayed on the right (e.g. "⌘K").

DropdownCheckboxItem props

Props

PropTypeDefaultDescription
checkedbooleanControlled checked state.
onCheckedChange / v-model:checked(v: boolean) => voidCalled when item is toggled.
disabledbooleanfalsePrevents interaction.
shortcutstringKeyboard hint on the right.

DropdownRadioGroup props

Props

PropTypeDefaultDescription
value / v-modelstringCurrently selected value.
onValueChange(value: string) => void(React) Called when selection changes.

DropdownSub props

Props

PropTypeDefaultDescription
triggerReactNode / stringLabel shown in the parent menu for the submenu trigger.
iconReactNodeOptional icon to the left of the trigger label.
placement"right" | "left""right"Which side the submenu opens on.
disabledbooleanfalsePrevents the submenu from opening.