Dropdown Menu

Dropdown Menu

Displays a menu to the user — such as a set of actions or functions — triggered by a button.

Usage

Import all parts and piece them together. It's mandatory to wrap the whole component with the Tailwind tag.

const { Tailwind } = VM.require("uiisnear.near/widget/tailwind");
const {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuGroup,
  DropdownMenuItem,
  DropdownMenuLabel,
  DropdownMenuSeparator,
  DropdownMenuShortcut,
  DropdownMenuSub,
  DropdownMenuSubContent,
  DropdownMenuSubTrigger,
  DropdownMenuTrigger,
  dropdownMenuContentClassname,
} = VM.require("uiisnear.near/widget/dropdownMenu");
 
if (Tailwind == undefined) return "";
<Tailwind>
  <DropdownMenu>
    <DropdownMenuTrigger>Open</DropdownMenuTrigger>
    <DropdownMenuContent>
      <DropdownMenuLabel>My Account</DropdownMenuLabel>
      <DropdownMenuSeparator />
      <DropdownMenuItem>Profile</DropdownMenuItem>
      <DropdownMenuItem>Billing</DropdownMenuItem>
      <DropdownMenuItem>Team</DropdownMenuItem>
      <DropdownMenuItem>Subscription</DropdownMenuItem>
    </DropdownMenuContent>
  </DropdownMenu>
</Tailwind>

API Reference

DropdownMenu

Contains all the parts of a dropdown menu.

PropTypeDefault
defaultOpen
boolean
---
open
boolean
---
onOpenChange
function
---
modal
boolean
true
dir
enum
---

DropdownMenuTrigger

The button that toggles the dropdown menu. By default, the DropdownMenuContent will position itself against the trigger.

Data attributeValues
[data-state]"open" | "closed"
[data-disabled]Present when disabled

DropdownMenuContent

The component that pops out when the dropdown menu is open.

PropTypeDefault
loop
boolean
false
onCloseAutoFocus
function
---
onEscapeKeyDown
function
---
onPointerDownOutside
function
---
onFocusOutside
function
---
onInteractOutside
function
---
forceMount
boolean
---
side
enum
"bottom"
sideOffset
number
0
align
enum
"center"
alignOffset
number
0
avoidCollisions
boolean
true
collisionBoundary
Boundary
[]
collisionPadding
number | Padding
0
arrowPadding
number
0
sticky
enum
"partial"
hideWhenDetached
boolean
false
Data attributeValues
[data-state]"open" | "closed"
[data-side]"left" | "right" | "bottom" | "top"
[data-align]"start" | "end" | "center"
[data-orientation]"vertical" | "horizontal"

DropdownMenuItem

The component that contains the dropdown menu items.

PropTypeDefault
disabled
boolean
---
onSelect
function
---
textValue
string
---
inset
boolean
---
Data attributeValues
[data-orientation]"vertical" | "horizontal"
[data-highlighted]Present when highlighted
[data-disabled]Present when disabled

DropdownMenuGroup

Used to group multiple DropdownMenuItems.

DropdownMenuLabel

Used to render a label. It won't be focusable using arrow keys.

PropTypeDefault
inset
boolean
---

DropdownMenuCheckboxItem

An item that can be controlled and rendered like a checkbox.

PropTypeDefault
checked
boolean | 'indeterminate'
---
onCheckedChange
function
---
disabled
boolean
---
onSelect
function
---
textValue
string
---
Data attributeValues
[data-state]"checked" | "unchecked" | "indeterminate"
[data-highlighted]Present when highlighted
[data-disabled]Present when disabled

DropdownMenuRadioGroup

Used to group multiple DropdownMenuRadioItems.

PropTypeDefault
value
string
---
onValueChange
function
---

DropdownMenuRadioItem

An item that can be controlled and rendered like a radio.

PropTypeDefault
value*
string
---
disabled
boolean
---
onSelect
function
---
textValue
string
---
Data attributeValues
[data-state]"checked" | "unchecked" | "indeterminate"
[data-highlighted]Present when highlighted
[data-disabled]Present when disabled

DropdownMenuSeparator

Used to visually separate items in the dropdown menu.

DropdownMenuSub

Contains all the parts of a submenu.

PropTypeDefault
defaultOpen
boolean
---
open
boolean
---
onOpenChange
function
---

DropdownMenuSubTrigger

An item that opens a submenu. Must be rendered inside DropdownMenuSub.

PropTypeDefault
disabled
boolean
---
textValue
string
---
inset
boolean
---
Data attributeValues
[data-state]"open" | "closed"
[data-highlighted]Present when highlighted
[data-disabled]Present when disabled

DropdownMenuSubContent

The component that pops out when a submenu is open. Must be rendered inside DropdownMenuSub.

PropTypeDefault
loop
boolean
false
onEscapeKeyDown
function
---
onPointerDownOutside
function
---
onFocusOutside
function
---
onInteractOutside
function
---
forceMount
boolean
---
sideOffset
number
0
alignOffset
number
0
avoidCollisions
boolean
true
collisionBoundary
Boundary
[]
collisionPadding
number | Padding
0
arrowPadding
number
0
sticky
enum
"partial"
hideWhenDetached
boolean
false
Data attributeValues
[data-state]"open" | "closed"
[data-side]"left" | "right" | "bottom" | "top"
[data-align]"start" | "end" | "center"
[data-orientation]"vertical" | "horizontal"

Classnames

Classnames available to customize the component.

FunctionClassname
DropdownMenuSubTriggerdropdownMenuSubTriggerClassname
DropdownMenuSubContentdropdownMenuSubContentClassname
DropdownMenuContentdropdownMenuContentClassname
DropdownMenuItemdropdownMenuItemClassname
DropdownMenuCheckboxItemdropdownMenuCheckboxItemClassname
DropdownMenuRadioItemdropdownMenuRadioItemClassname
DropdownMenuLabeldropdownMenuLabelClassname
DropdownMenuSeparatordropdownMenuSeparatorClassname
DropdownMenuShortcutdropdownMenuShortcutClassname