Import
import {
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuGroup,
DropdownMenuItem,
DropdownMenuShortcut,
DropdownMenuSub,
DropdownMenuSubTrigger,
DropdownMenuPortal,
DropdownMenuSubContent
} from '@strongtie/design-system/dropdown-menu';
Usage
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="outline">
Open <MdKeyboardArrowDown />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuLabel>My Account</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem>
Profile
<DropdownMenuShortcut>⇧⌘P</DropdownMenuShortcut>
</DropdownMenuItem>
<DropdownMenuItem>
Billing
<DropdownMenuShortcut>⌘B</DropdownMenuShortcut>
</DropdownMenuItem>
<DropdownMenuItem>
Settings
<DropdownMenuShortcut>⌘S</DropdownMenuShortcut>
</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem>Team</DropdownMenuItem>
<DropdownMenuSub>
<DropdownMenuSubTrigger>
Invite users
</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<DropdownMenuSubContent>
<DropdownMenuItem>Email</DropdownMenuItem>
<DropdownMenuItem>Message</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem>More...</DropdownMenuItem>
</DropdownMenuSubContent>
</DropdownMenuPortal>
</DropdownMenuSub>
<DropdownMenuItem>
New Team
<DropdownMenuShortcut>⌘+T</DropdownMenuShortcut>
</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuItem disabled>API</DropdownMenuItem>
<DropdownMenuItem>
Log out
<DropdownMenuShortcut>⇧⌘Q</DropdownMenuShortcut>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
The open state of the dropdown menu when it is initially rendered.
The controlled open state of the dropdown menu.
Event handler called when the open state of the dropdown menu changes.
The modality of the dropdown menu. When set to true, interaction with outside elements will be disabled and only menu content will be visible to screen readers.
The reading direction of submenus when applicable
If true, the component will render as a child of the parent component.
<DropdownPortal> Props
container
HTMLElement
default:"document.body"
The container element to which the dropdown menu will be appended.
If true, the dropdown menu will be mounted to the container regardless of its position in the DOM.
If true, the component will render as a child of the parent component.
If true, the dropdown menu will loop when navigating with arrow keys.
Event handler called when the dropdown menu is closed and focus is returned to the trigger.
Event handler called when the escape key is pressed while the dropdown menu is open.
Event handler called when a pointer is pressed outside the dropdown menu.
Event handler called when focus is moved outside the dropdown menu.
Event handler called when interaction occurs outside the dropdown menu.
If true, the dropdown menu will be mounted to the container
side
"top" | "right" | "bottom" | "left"
default:"bottom"
The side of the trigger where the dropdown menu will be positioned.
The distance in pixels from the trigger.
align
"start" | "center" | "end"
default:"start"
The preferred alignment against the trigger.
The distance in pixels from the trigger.
If true, the dropdown menu will avoid collisions with the viewport.
The boundary element to which the dropdown menu will be constrained.
collisionPadding
number | Padding
default:"0"
The padding in pixels to be applied to the collision boundary.
The padding in pixels to be applied to the arrow element.
sticky
"partial" | "always"
default:"partial"
If true, the dropdown menu will be sticky to the viewport.
If true, the dropdown menu will be hidden when it is detached from the trigger.
If true, the component will render as a child of the parent component.
Event handler called when the item is selected.
Optional text used for typeahead purposes
Whether to render the item with indentation to account for the presence of a checkbox or radio indicator.
When true, prevents the user from interacting with the item.
If true, the component will render as a child of the parent component.
The controlled checked state of the item.
Event handler called when the checked state changes.
When true, prevents the user from interacting with the item.
Event handler called when the item is selected.
Optional text used for typeahead purposes
If true, the component will render as a child of the parent component.
The value of the selected item in the group.
Event handler called when the value changes.
If true, the component will render as a child of the parent component.
The unique value of the item.
When true, prevents the user from interacting with the item.
Event handler called when the item is selected.
Optional text used for typeahead purposes
The open state of the submenu when it is initially rendered.
The controlled open state of the submenu.
Event handler called when the open state of the submenu changes.
If true, the component will render as a child of the parent component.
Whether to render the trigger with indentation.
When true, prevents the user from interacting with the trigger.
Optional text used for typeahead purposes
If true, the component will render as a child of the parent component.
Styling Classes
The following CSS classes are applied by the Dropdown Menu components:
dropdown-menu-content – Main dropdown container
dropdown-menu-sub-content – Sub-menu container
menu-item – Base menu item class
menu-item-sub-trigger – Sub-menu trigger item
menu-item-checkbox – Checkbox menu item
menu-item-radio – Radio menu item
menu-item-label – Menu label/header
menu-item-separator – Menu separator line
menu-item-shortcut – Keyboard shortcut display
menu-item-indicator – Checkbox/radio indicator wrapper
-inset – Inset modifier for indented items
For more examples, visit the Storybook.<StudsDropdownMenu>
<StudsDropdownMenuTrigger>Menu</StudsDropdownMenuTrigger>
<StudsDropdownMenuContent>
<StudsDropdownMenuLabel Text="Options"></StudsDropdownMenuLabel>
<StudsDropdownMenuItem Text="Action" Shortcut="⇧⌘P"></StudsDropdownMenuItem>
<StudsDropdownMenuItem Text="Another Action" Shortcut="⇧⌘M"></StudsDropdownMenuItem>
<StudsDropdownMenuSeperator></StudsDropdownMenuSeperator>
<StudsDropdownMenuItem Text="More Actions" Shortcut="⇧⌘A"></StudsDropdownMenuItem>
</StudsDropdownMenuContent>
</StudsDropdownMenu>
Variant
DropdownMenuVariant
default:"Default"
Gets or sets the variant style of the dropdown menu. Options include Default, Checkbox, and Radio.
Click
EventCallback<StudsDropdownMenuItem>
Gets or sets the callback that is invoked when a menu item is clicked.
SelectionChanged
EventCallback<IEnumerable<StudsDropdownMenuItem>>
Event fired when a selection changes in checkbox or radio mode.
Gets or sets the child content.
Attributes
Dictionary<string, object>
Specifies additional custom attributes that will be rendered by the component.
MouseEnter
EventCallback<ElementReference>
Gets or sets the callback that is invoked when the mouse enters an item.
MouseLeave
EventCallback<ElementReference>
Gets or sets the callback that is invoked when the mouse leaves an item.
A callback that will be invoked when the user right-clicks the component. Commonly used to display a context menu.
Culture
CultureInfo
default:"CultureInfo.CurrentCulture"
Gets or sets the culture used to display localizable data (numbers, dates). Set by default to “CultureInfo.CurrentCulture”.
Gets or sets the inline CSS style.
Gets or sets a value indicating whether this “T:Studs.StudsComponent” is visible. Invisible components are not rendered.
The content to be rendered inside the dropdown menu trigger.
Gets or sets the child content to be displayed within the dropdown menu.
Gets or sets the child content. When provided, the item becomes a submenu.
Gets or sets the text displayed in the menu item.
Gets or sets the keyboard shortcut text displayed on the right side of the menu item.
Gets or sets the value associated with the menu item.
Gets or sets whether the item is selected. Used with Checkbox and Radio variants.
Event callback when the selection state changes.
OnClick
EventCallback<MouseEventArgs>
Gets or sets the custom click callback for the menu item.
Attributes
Dictionary<string, object>
Specifies additional custom attributes that will be rendered by the component.
MouseEnter
EventCallback<ElementReference>
Gets or sets the callback that is invoked when the mouse enters an item.
MouseLeave
EventCallback<ElementReference>
Gets or sets the callback that is invoked when the mouse leaves an item.
A callback that will be invoked when the user right-clicks the component. Commonly used to display a context menu.
Culture
CultureInfo
default:"CultureInfo.CurrentCulture"
Gets or sets the culture used to display localizable data (numbers, dates). Set by default to “CultureInfo.CurrentCulture”.
Gets or sets the inline CSS style.
Gets or sets a value indicating whether this “T:Studs.StudsComponent” is visible. Invisible components are not rendered.
Gets or sets the child content.
Gets or sets the text for the label.
Attributes
Dictionary<string, object>
Specifies additional custom attributes that will be rendered by the component.
MouseEnter
EventCallback<ElementReference>
Gets or sets the callback that is invoked when the mouse enters an item.
MouseLeave
EventCallback<ElementReference>
Gets or sets the callback that is invoked when the mouse leaves an item.
A callback that will be invoked when the user right-clicks the component. Commonly used to display a context menu.
Culture
CultureInfo
default:"CultureInfo.CurrentCulture"
Gets or sets the culture used to display localizable data (numbers, dates). Set by default to “CultureInfo.CurrentCulture”.
Gets or sets the inline CSS style.
Gets or sets a value indicating whether this “T:Studs.StudsComponent” is visible. Invisible components are not rendered.
Attributes
Dictionary<string, object>
Specifies additional custom attributes that will be rendered by the component.
MouseEnter
EventCallback<ElementReference>
Gets or sets the callback that is invoked when the mouse enters an item.
MouseLeave
EventCallback<ElementReference>
Gets or sets the callback that is invoked when the mouse leaves an item.
A callback that will be invoked when the user right-clicks the component. Commonly used to display a context menu.
Culture
CultureInfo
default:"CultureInfo.CurrentCulture"
Gets or sets the culture used to display localizable data (numbers, dates). Set by default to “CultureInfo.CurrentCulture”.
Gets or sets the inline CSS style.
Gets or sets a value indicating whether this “T:Studs.StudsComponent” is visible. Invisible components are not rendered.
Styling Classes
The following CSS classes are applied by the Dropdown Menu components:
dropdown-menu – Base dropdown menu container
menu-trigger – Trigger button for the dropdown menu
menu-popup – Popup menu container
menu-item – Individual menu item wrapper
menu-item-label - Menu item label to indicate grouped menu items
menu-item-icon – Icon wrapper for menu items if property @DropdownMenuVariant is set
menu-item-text – Text wrapper for menu items if property @Text is not null
menu-item-content – Content wrapper for menu items
menu-submenu – Submenu container
menu-item-shortcut – Shortcut text for menu items
menu-item-submenu-icon – Icon for submenu trigger indicator
For more examples, visit the Storybook.