Dropdown

The Dropdown component provides a versatile way to display a list of actions or options in a temporary, contextual menu that appears when a user interacts with a trigger element.

Installation

$ cbui-cli install @crossbuildui/dropdown

Import

MyComponent.tsx
1import { 2 Dropdown, 3 DropdownTrigger, 4 DropdownMenu, 5 DropdownItem, 6 DropdownSection 7} from '@/crossbuildui/dropdown'; 8import type { DropdownColor, DropdownSelectionMode, DropdownVariant } from '@/crossbuildui/dropdown'; // Optional 9import { Button } from '@/crossbuildui/button'; // Or your preferred trigger

Dropdown Components

Props Overview

Dropdown Props

PROPTYPEDESCRIPTION
children[Trigger, Menu]Must be DropdownTrigger followed by DropdownMenu.

DropdownTrigger Props

PROPTYPEDESCRIPTION
childrenReactNodeThe trigger element (e.g., Button).
styleStyleProp<ViewStyle>Style for the trigger wrapper View.

DropdownMenu Props

PROPTYPEDEFAULTDESCRIPTION
childrenReactNode | (item) => Element-Static items or render function for dynamic items.
itemsT[]-Array of data for dynamic rendering.
renderItem(item: T) => Element-Render function for dynamic items if children is not a function.
variantDropdownVariant'solid'Visual style of the menu.
colorDropdownColor'default'Thematic color of the menu.
selectionModeDropdownSelectionMode'none'Selection behavior.
selectedKeysIterable<string|number>-Controlled selected item keys.
defaultSelectedKeysIterable<string|number>[]Uncontrolled initial selected keys.
disabledKeysIterable<string|number>[]Keys of items to disable.
disallowEmptySelectionbooleanfalsePrevent deselection to an empty state.
topContentReactNode-Content to display above the items.
bottomContentReactNode-Content to display below the items.
emptyContentReactNodeDefault TextContent when no items are available.
hideSelectedIconbooleanfalseHide selection indicator for all items in this menu.
closeOnSelectbooleanContext-based (true)Whether to close the menu on item selection.
disableAnimationbooleanfalseDisable menu open/close animation.
styleStyleProp<ViewStyle>-Style for the menu container.
itemStylePartial<DropdownItemSlots>-Default styles for direct child item slots.
onSelectionChange(keys: Set) => void-Callback when selection changes.

DropdownItem Props

PROPTYPEDEFAULTDESCRIPTION
childrenReactNode-Primary content, overrides title.
itemKeystring | numberRequiredUnique key for the item.
titleReactNode-Title of the item if children not provided.
textValuestring-Plain text for accessibility/typeahead.
descriptionReactNode-Additional descriptive text.
startContentReactNode-Content to render before the title/description.
endContentReactNode-Content to render after the selected icon.
selectedIconReactNode | (props) => NodeDefault Check IconCustom selection indicator.
showDividerbooleanfalseShow a divider after this item.
hideSelectedIconbooleanContext-basedOverride menu/section setting for this item.
styleStyleProp<ViewStyle>-Style for the item's outer Pressable.
slotStylesPartial<DropdownItemSlots>-Styles for inner parts of the item.
isDisabledbooleanfalseExplicitly disable this item.

DropdownSection Props

PROPTYPEDEFAULTDESCRIPTION
childrenReactNodeRequiredDropdownItems within this section.
itemKeystring | numberRequiredUnique key for the section.
titlestring-Title for the section.
hideSelectedIconbooleanContext-basedOverride menu setting for items in this section.
showDividerbooleanfalseShow a divider after the section.
dividerPropsStyleProp<ViewStyle>-Style for the section divider.
styleStyleProp<ViewStyle>-Style for the section wrapper.
itemStylePartial<DropdownItemSlots>-Default styles for item slots in this section.