Tally UI
Primitives

DropdownMenu

A menu of actions triggered by a button, supporting items, checkboxes, radio groups, and submenus.

Import

import { DropdownMenu } from '@tallyui/primitives';

Usage

<DropdownMenu.Root open={open} onOpenChange={setOpen}>
  <DropdownMenu.Trigger>
    <Text>Options</Text>
  </DropdownMenu.Trigger>
  <DropdownMenu.Portal>
    <DropdownMenu.Overlay />
    <DropdownMenu.Content sideOffset={4}>
      <DropdownMenu.Item>
        <Text>Edit</Text>
      </DropdownMenu.Item>
      <DropdownMenu.Separator />
      <DropdownMenu.Item>
        <Text>Delete</Text>
      </DropdownMenu.Item>
    </DropdownMenu.Content>
  </DropdownMenu.Portal>
</DropdownMenu.Root>

Components

Manages the open/closed state. Does not render a DOM element.

PropTypeDefaultDescription
openbooleanControlled open state
defaultOpenbooleanfalseInitial state (uncontrolled)
onOpenChange(open: boolean) => voidCalled when open state changes

A pressable that opens the menu.

PropTypeDefaultDescription
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native PressableProps.

Renders children into a portal.

PropTypeDefaultDescription
forceMounttrueAlways mount portal content
hostNamestringTarget portal host name

An optional backdrop behind the menu.

PropTypeDefaultDescription
closeOnPressbooleantrueWhether pressing the overlay closes the menu
forceMounttrueAlways render the overlay
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native PressableProps.

The positioned menu panel. Accepts all PositionedContentProps.

PropTypeDefaultDescription
side'top' | 'bottom''bottom'Preferred side relative to the trigger
sideOffsetnumber0Distance from the trigger
align'start' | 'center' | 'end''center'Alignment along the trigger
avoidCollisionsbooleantrueShift to stay within the viewport
forceMounttrueAlways render the content
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native ViewProps.

A menu action item.

PropTypeDefaultDescription
textValuestringText for typeahead search
closeOnPressbooleantrueWhether selecting closes the menu
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native PressableProps.

A menu item that toggles a boolean value.

PropTypeDefaultDescription
checkedbooleanrequiredWhether the item is checked
onCheckedChange(checked: boolean) => voidrequiredCalled when checked state changes
textValuestringText for typeahead search
closeOnPressbooleantrueWhether selecting closes the menu
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native PressableProps.

Groups radio items for mutually exclusive selection.

PropTypeDefaultDescription
valuestring | undefinedrequiredThe currently selected value
onValueChange(value: string) => voidrequiredCalled when selection changes
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native ViewProps.

A radio option inside a RadioGroup.

PropTypeDefaultDescription
valuestringrequiredThe value for this option
textValuestringText for typeahead search
closeOnPressbooleantrueWhether selecting closes the menu
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native PressableProps.

Renders when the parent CheckboxItem or RadioItem is selected.

PropTypeDefaultDescription
forceMounttrueAlways render regardless of selection
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native ViewProps.

Groups related items together.

PropTypeDefaultDescription
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native ViewProps.

A label for a Group.

PropTypeDefaultDescription
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native TextProps.

A visual divider between items or groups.

PropTypeDefaultDescription
decorativebooleanfalseRemoves from accessibility tree
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native ViewProps.

A nested submenu root.

PropTypeDefaultDescription
openbooleanControlled open state
defaultOpenbooleanfalseInitial state (uncontrolled)
onOpenChange(open: boolean) => voidCalled when open state changes

A menu item that opens a submenu.

PropTypeDefaultDescription
textValuestringText for typeahead search
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native PressableProps.

The content of a submenu.

PropTypeDefaultDescription
forceMounttrueAlways render the content
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native ViewProps.

Accessibility

  • Role: menu on Content, menuitem on Item, menuitemcheckbox on CheckboxItem, menuitemradio on RadioItem
  • ARIA: aria-expanded on Trigger, aria-checked on CheckboxItem and RadioItem
  • Arrow key navigation, typeahead search, and Escape to close on web

On this page