Overlays

Dropdown menu.

Actions for the thing you are working on.

LIVE PREVIEWTry it. It works.

Install the source

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/dropdown.json

Registry setup · Examples · API and behavior · Open the playground

COMPLETE EXAMPLES

Use it in context.

Each example includes its imports, data and state. The preview runs that same source. Include the stylesheet once in your application.

Groups and nested actions

Move a record through a submenu, inspect a disabled destination and restore the example. Changes stay in this example.

Keyboard

  • Arrow Down opens the menu. Up and Down move through enabled items.
  • Right opens Move to; Left returns to its parent. Escape closes and returns focus.
  • The shortcut hint is display text; applications register their own shortcuts.

States covered

  • Enabled and disabled actions
  • Grouped items and separators
  • Nested keyboard navigation
  • Local record state and focus return

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-dropdown-actions.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import '@bld8/ui/styles.css';
import { useState } from 'react';
import { Button, DropdownMenu, type DropdownMenuEntry } from '@bld8/ui';
import { Check, FolderInput, RotateCcw } from 'lucide-react';

export function RecordActionsExample() {
  const [reviewed, setReviewed] = useState(false);
  const [location, setLocation] = useState('Inbox');
  const items: DropdownMenuEntry[] = [
    { type: 'group', label: 'Record', items: [
      { label: 'Mark reviewed', icon: Check, shortcut: 'R', disabled: reviewed, onSelect: () => setReviewed(true) },
      { type: 'submenu', label: 'Move to', icon: FolderInput, items: [
        { label: 'Inbox', onSelect: () => setLocation('Inbox') },
        { label: 'Review queue', onSelect: () => setLocation('Review queue') },
        { label: 'Restricted area', disabled: true },
      ] },
    ] },
    { type: 'separator' },
    { label: 'Restore record example', icon: RotateCcw, destructive: true, onSelect: () => { setReviewed(false); setLocation('Inbox'); } },
  ];
  return <div style={{ display: 'flex', flexDirection: 'column', gap: 20, width: '100%' }}>
    <DropdownMenu trigger={<Button variant="secondary">Record actions</Button>} items={items} />
    <p role="status">{reviewed ? 'Reviewed' : 'Not reviewed'} · Location: {location}</p>
    <p className="bui-hint">Local example state. No record is written to a service.</p>
  </div>;
}

Checkbox and radio preferences

Controlled checkbox and radio values remain editable while the menu stays open.

Keyboard

  • Space toggles Show labels without closing the menu.
  • Move to a spacing option and press Space or Enter to choose it.
  • Escape or Close view preferences returns focus to the trigger.

States covered

  • Controlled popup
  • Controlled checkbox
  • Controlled radio group
  • Disabled radio option
  • State retained across reopening

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-dropdown-preferences.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import '@bld8/ui/styles.css';
import { useState } from 'react';
import { Button, DropdownMenu, type DropdownMenuEntry } from '@bld8/ui';

export function ViewPreferencesExample() {
  const [open, setOpen] = useState(false);
  const [labels, setLabels] = useState(true);
  const [spacing, setSpacing] = useState('comfortable');
  const items: DropdownMenuEntry[] = [
    { type: 'group', label: 'Display', items: [
      { type: 'checkbox', label: 'Show labels', checked: labels, onCheckedChange: setLabels },
    ] },
    { type: 'separator' },
    { type: 'radio-group', label: 'Row spacing', value: spacing, onValueChange: setSpacing, items: [
      { value: 'compact', label: 'Compact spacing' },
      { value: 'comfortable', label: 'Comfortable spacing' },
      { value: 'automatic', label: 'Automatic spacing', disabled: true },
    ] },
    { type: 'separator' },
    { label: 'Close view preferences', onSelect: () => setOpen(false) },
  ];
  return <div style={{ display: 'flex', flexDirection: 'column', gap: 20, width: '100%' }}>
    <DropdownMenu trigger={<Button variant="secondary">View preferences</Button>} items={items} open={open} onOpenChange={setOpen} />
    <p role="status">{labels ? 'Labels visible' : 'Labels hidden'} · {spacing === 'compact' ? 'Compact spacing' : 'Comfortable spacing'}</p>
  </div>;
}

Quick reference

React / TypeScript
<DropdownMenu trigger={<Button variant="secondary">Actions</Button>} items={[{label:"Duplicate",onSelect:duplicate},{label:"Archive",onSelect:archive}]} />

In the workspace or ZIP starter, import components from @bld8/ui and include @bld8/ui/styles.css once. Registry installations use your local bld8/ source path. Wrap overlays in UIProvider.

API & behaviour

Built on Base UI Menu. Existing action objects support label, onSelect, disabled, destructive, icon and shortcut. Discriminated items add groups, separators, submenus, checkbox choices and radio groups. Controlled/default open state and aligned portalled popups preserve keyboard arrows, dismissal and return focus. Callbacks own application changes.

DropdownMenu

DropdownMenu public properties
PropTypeDefault
itemsRequiredreadonly DropdownMenuEntry[]—
triggerRequiredReactElement<unknown, string | JSXElementConstructor<any>>—
align"center" | "start" | "end" | undefined'end'
defaultOpenboolean | undefined—
onOpenChange((open: boolean) => void) | undefined—
openboolean | undefined—
sideOffsetnumber | undefined8

MenuItem

MenuItem public properties
PropTypeDefault
labelRequiredstring—
closeOnSelectboolean | undefined—
descriptionstring | undefined—
destructiveboolean | undefined—
disabledboolean | undefined—
iconLucideIcon | undefined—
idstring | undefined—
onSelect(() => void) | undefined—
shortcutstring | undefined—

DropdownMenuEntry

MenuActionItem|MenuCheckboxItem|MenuRadioGroup|MenuItemGroup|MenuSubmenu|MenuSeparator

DropdownMenuEntry public properties
PropTypeDefault
idstring | undefined—
type"checkbox" | "group" | "separator" | "item" | "radio-group" | "submenu" | undefined—

MenuActionItem

MenuActionItem public properties
PropTypeDefault
labelRequiredstring—
closeOnSelectboolean | undefined—
descriptionstring | undefined—
destructiveboolean | undefined—
disabledboolean | undefined—
iconLucideIcon | undefined—
idstring | undefined—
onSelect(() => void) | undefined—
shortcutstring | undefined—
type"item" | undefined—

MenuCheckboxItem

MenuCheckboxItem public properties
PropTypeDefault
labelRequiredstring—
typeRequired"checkbox"—
checkedboolean | undefined—
closeOnSelectboolean | undefined—
defaultCheckedboolean | undefined—
descriptionstring | undefined—
disabledboolean | undefined—
iconLucideIcon | undefined—
idstring | undefined—
onCheckedChange((checked: boolean) => void) | undefined—
shortcutstring | undefined—

MenuRadioOption

MenuRadioOption public properties
PropTypeDefault
labelRequiredstring—
valueRequiredstring—
descriptionstring | undefined—
disabledboolean | undefined—
iconLucideIcon | undefined—
idstring | undefined—
shortcutstring | undefined—

MenuRadioGroup

MenuRadioGroup public properties
PropTypeDefault
itemsRequiredreadonly MenuRadioOption[]—
labelRequiredstring—
typeRequired"radio-group"—
closeOnSelectboolean | undefined—
defaultValuestring | undefined—
disabledboolean | undefined—
idstring | undefined—
onValueChange((value: string) => void) | undefined—
valuestring | undefined—

MenuItemGroup

MenuItemGroup public properties
PropTypeDefault
itemsRequiredreadonly DropdownMenuEntry[]—
typeRequired"group"—
idstring | undefined—
labelstring | undefined—

MenuSubmenu

MenuSubmenu public properties
PropTypeDefault
itemsRequiredreadonly DropdownMenuEntry[]—
labelRequiredstring—
typeRequired"submenu"—
descriptionstring | undefined—
disabledboolean | undefined—
iconLucideIcon | undefined—
idstring | undefined—
shortcutstring | undefined—

MenuSeparator

MenuSeparator public properties
PropTypeDefault
typeRequired"separator"—
idstring | undefined—

Tables come from the public TypeScript declarations. Related types and function parameters are shown alongside their component. A dash means no default is declared at the public function boundary.

Related controls

Notes to self

Test this component with real content, keyboard input and both themes. The example is a starting point; labels, error handling and behaviour still need to fit the application.