Dropdown Menu
StableMenu de ações ancorado a um gatilho, com grupos, rótulos, submenus, itens de checkbox e de rádio. Composto sobre Base UI Menu. A diferença para o Popover não é visual: um menu tem papel `menu`, foco itinerante pelas setas e typeahead, e dentro dele Tab sai em vez de andar entre campos — por isso uma lista de ações mora aqui e um formulário não.
Instalação
npx up-web-ds add dropdown-menuGera check, chevron-right para a biblioteca de ícones do projeto (components.json → iconLibrary).
Preview
Default
With Groups
With State
With Submenu
States
All states
Default
With Groups
With State
With Submenu
States
Usage
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuShortcut,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu'
import { Button } from '@/components/ui/button'1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16<DropdownMenu>
<DropdownMenuTrigger render={<Button variant="outline" />}>
Ações do item
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuItem>
Abrir no catálogo
<DropdownMenuShortcut>⌘O</DropdownMenuShortcut>
</DropdownMenuItem>
<DropdownMenuItem>
Copiar comando de instalação
<DropdownMenuShortcut>⌘C</DropdownMenuShortcut>
</DropdownMenuItem>
<DropdownMenuItem>Regenerar catálogo</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>Props
DropdownMenu
| Prop | Type | Default | Description |
|---|---|---|---|
| actionsRef | React.RefObject<MenuRootActions | null> | —sem valor padrão | A ref to imperative actions. - `unmount`: Manually unmounts the menu. Call this after any externally controlled closing animation finishes. - `close`: When specified, the menu can be closed imperatively. |
| children | React.ReactNode | PayloadChildRenderFunction<unknown> | —sem valor padrão | The content of the menu. This can be a regular React node or a render function that receives the `payload` of the active trigger. |
| closeParentOnEsc | boolean | false | When in a submenu, determines whether pressing the Escape key closes the entire menu, or only the current child menu. |
| defaultOpen | boolean | false | Whether the menu is initially open. To render a controlled menu, use the `open` prop instead. |
| defaultTriggerId | string | null | —sem valor padrão | ID of the trigger that the menu is associated with. This is useful in conjunction with the `defaultOpen` prop to create an initially open menu. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| handle | MenuHandle<unknown> | —sem valor padrão | A handle to associate the menu with a trigger. If specified, allows external triggers to control the menu's open state. |
| highlightItemOnHover | boolean | true | Whether moving the pointer over items should highlight them. Disabling this prop allows CSS `:hover` to be differentiated from the `:focus` (`data-highlighted`) state. |
| loopFocus | boolean | true | Whether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys. |
| modal | boolean | true | Determines if the menu enters a modal state when open. - `true`: user interaction is limited to the menu: document page scroll is locked and pointer interactions on outside elements are disabled. - `false`: user interaction with the rest of the document is allowed. On touch devices, a `true` modal blocks outside taps but leaves the page scrollable unless the popup spans nearly the full viewport width, matching native iOS behavior. Nested menus ignore this prop, and menus opened by hover are never modal. |
| onOpenChange | ((open: boolean, eventDetails: MenuRoot.ChangeEventDetails) => void) | —sem valor padrão | Event handler called when the menu is opened or closed. |
| onOpenChangeComplete | ((open: boolean) => void) | —sem valor padrão | Event handler called after any animations complete when the menu is opened or closed. |
| open | boolean | —sem valor padrão | Whether the menu is currently open. |
| orientation | MenuRootOrientation | 'vertical' | The visual orientation of the menu. Controls whether roving focus uses up/down or left/right arrow keys. |
| triggerId | string | null | —sem valor padrão | ID of the trigger that the menu is associated with. This is useful in conjunction with the `open` prop to create a controlled menu. There's no need to specify this prop when the menu is uncontrolled (that is, when the `open` prop is not set). |
Estende MenuPrimitive.Root.Props.
DropdownMenuPortal
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | ((state: MenuPortalState) => string | undefined) | —sem valor padrão | CSS class applied to the element, or a function that returns a class based on the component's state. |
| container | HTMLElement | ShadowRoot | React.RefObject<HTMLElement | ShadowRoot | null> | null | —sem valor padrão | A parent element to render the portal element into. |
| keepMounted | boolean | false | Whether to keep the portal mounted in the DOM while the popup is hidden. |
| render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuPortalState> | —sem valor padrão | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties | ((state: MenuPortalState) => React.CSSProperties | undefined) | —sem valor padrão | Style applied to the element, or a function that returns a style object based on the component's state. |
Estende MenuPrimitive.Portal.Props. Aceita também os atributos padrão de um elemento React (275 não listados).
DropdownMenuTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
| children | React.ReactNode | —sem valor padrão | |
| className | string | ((state: MenuTriggerState) => string | undefined) | —sem valor padrão | CSS class applied to the element, or a function that returns a class based on the component's state. |
| closeDelay | number | 0 | How long to wait before closing the menu that was opened on hover. Specified in milliseconds. Requires the `openOnHover` prop. |
| delay | number | 100 | How long to wait before the menu may be opened on hover. Specified in milliseconds. Requires the `openOnHover` prop. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| handle | MenuHandle<unknown> | —sem valor padrão | A handle to associate the trigger with a menu. |
| nativeButton | boolean | true | Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`). |
| openOnHover | boolean | —sem valor padrão | Whether the menu should also open when the trigger is hovered. |
| payload | unknown | —sem valor padrão | A payload to pass to the menu when it is opened. |
| render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuTriggerState> | —sem valor padrão | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties | ((state: MenuTriggerState) => React.CSSProperties | undefined) | —sem valor padrão | Style applied to the element, or a function that returns a style object based on the component's state. |
Estende MenuPrimitive.Trigger.Props. Aceita também os atributos padrão de um elemento React (283 não listados).
DropdownMenuContent
| Prop | Type | Default | Description |
|---|---|---|---|
| align | Align | 'start' | How to align the popup relative to the specified side. |
| alignOffset | number | OffsetFunction | 0 | Additional offset along the alignment axis in pixels. Also accepts a function that returns the offset to read the dimensions of the anchor and positioner elements, along with its side and alignment. The function takes a `data` object parameter with the following properties: - `data.anchor`: the dimensions of the anchor element with properties `width` and `height`. - `data.positioner`: the dimensions of the positioner element with properties `width` and `height`. - `data.side`: which side of the anchor element the positioner is aligned against. - `data.align`: how the positioner is aligned relative to the specified side. |
| children | React.ReactNode | —sem valor padrão | |
| className | string | ((state: MenuPopupState) => string | undefined) | —sem valor padrão | CSS class applied to the element, or a function that returns a class based on the component's state. |
| finalFocus | boolean | React.RefObject<HTMLElement | null> | ((closeType: InteractionType) => boolean | HTMLElement | null | void) | —sem valor padrão | Determines the element to focus when the menu is closed. - `false`: Do not move focus. - `true`: Move focus based on the default behavior (trigger or previously focused element). - `RefObject`: Move focus to the ref element. - `function`: Called with the interaction type (`mouse`, `touch`, `pen`, or `keyboard`). Return an element to focus, `true` to use the default behavior, or `false`/`undefined` to do nothing. |
| id | string | —sem valor padrão | |
| render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuPopupState> | —sem valor padrão | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| side | Side | 'bottom' | Which side of the anchor element to align the popup against. May automatically change to avoid collisions. |
| sideOffset | number | OffsetFunction | 4 | Distance between the anchor and the popup in pixels. Also accepts a function that returns the distance to read the dimensions of the anchor and positioner elements, along with its side and alignment. The function takes a `data` object parameter with the following properties: - `data.anchor`: the dimensions of the anchor element with properties `width` and `height`. - `data.positioner`: the dimensions of the positioner element with properties `width` and `height`. - `data.side`: which side of the anchor element the positioner is aligned against. - `data.align`: how the positioner is aligned relative to the specified side. |
| style | React.CSSProperties | ((state: MenuPopupState) => React.CSSProperties | undefined) | —sem valor padrão | Style applied to the element, or a function that returns a style object based on the component's state. |
Estende MenuPrimitive.Popup.Props & Pick< MenuPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset' >. Aceita também os atributos padrão de um elemento React (273 não listados).
DropdownMenuGroup
| Prop | Type | Default | Description |
|---|---|---|---|
| children | React.ReactNode | —sem valor padrão | The content of the component. |
| className | string | ((state: MenuGroupState) => string | undefined) | —sem valor padrão | CSS class applied to the element, or a function that returns a class based on the component's state. |
| render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuGroupState> | —sem valor padrão | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties | ((state: MenuGroupState) => React.CSSProperties | undefined) | —sem valor padrão | Style applied to the element, or a function that returns a style object based on the component's state. |
Estende MenuPrimitive.Group.Props. Aceita também os atributos padrão de um elemento React (274 não listados).
DropdownMenuLabel
| Prop | Type | Default | Description |
|---|---|---|---|
| inset | boolean | —sem valor padrão | |
| className | string | ((state: MenuGroupLabelState) => string | undefined) | —sem valor padrão | CSS class applied to the element, or a function that returns a class based on the component's state. |
| render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuGroupLabelState> | —sem valor padrão | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties | ((state: MenuGroupLabelState) => React.CSSProperties | undefined) | —sem valor padrão | Style applied to the element, or a function that returns a style object based on the component's state. |
Estende MenuPrimitive.GroupLabel.Props. Aceita também os atributos padrão de um elemento React (275 não listados).
DropdownMenuItem
| Prop | Type | Default | Description |
|---|---|---|---|
| inset | boolean | —sem valor padrão | |
| variant | "default" | "destructive" | 'default' | |
| className | string | ((state: MenuItemState) => string | undefined) | —sem valor padrão | CSS class applied to the element, or a function that returns a class based on the component's state. |
| closeOnClick | boolean | true | Whether to close the menu when the item is clicked. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| id | string | —sem valor padrão | |
| label | string | —sem valor padrão | Overrides the text label to use when the item is matched during keyboard text navigation. |
| nativeButton | boolean | false | Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `true` if the rendered element is a native button. |
| onClick | ((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | —sem valor padrão | The click handler for the menu item. |
| render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuItemState> | —sem valor padrão | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties | ((state: MenuItemState) => React.CSSProperties | undefined) | —sem valor padrão | Style applied to the element, or a function that returns a style object based on the component's state. |
Estende MenuPrimitive.Item.Props. Aceita também os atributos padrão de um elemento React (273 não listados).
DropdownMenuSub
| Prop | Type | Default | Description |
|---|---|---|---|
| actionsRef | React.RefObject<MenuRootActions | null> | —sem valor padrão | A ref to imperative actions. - `unmount`: Manually unmounts the menu. Call this after any externally controlled closing animation finishes. - `close`: When specified, the menu can be closed imperatively. |
| children | React.ReactNode | —sem valor padrão | The content of the submenu. |
| closeParentOnEsc | boolean | false | When in a submenu, determines whether pressing the Escape key closes the entire menu, or only the current child menu. |
| defaultOpen | boolean | false | Whether the menu is initially open. To render a controlled menu, use the `open` prop instead. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| highlightItemOnHover | boolean | true | Whether moving the pointer over items should highlight them. Disabling this prop allows CSS `:hover` to be differentiated from the `:focus` (`data-highlighted`) state. |
| loopFocus | boolean | true | Whether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys. |
| onOpenChange | ((open: boolean, eventDetails: MenuSubmenuRoot.ChangeEventDetails) => void) | —sem valor padrão | Event handler called when the menu is opened or closed. |
| onOpenChangeComplete | ((open: boolean) => void) | —sem valor padrão | Event handler called after any animations complete when the menu is opened or closed. |
| open | boolean | —sem valor padrão | Whether the menu is currently open. |
| orientation | MenuRootOrientation | 'vertical' | The visual orientation of the menu. Controls whether roving focus uses up/down or left/right arrow keys. |
Estende MenuPrimitive.SubmenuRoot.Props.
DropdownMenuSubTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
| inset | boolean | —sem valor padrão | |
| className | string | ((state: MenuSubmenuTriggerState) => string | undefined) | —sem valor padrão | CSS class applied to the element, or a function that returns a class based on the component's state. |
| closeDelay | number | 0 | How long to wait before closing the menu that was opened on hover. Specified in milliseconds. Requires the `openOnHover` prop. |
| delay | number | 100 | How long to wait before the menu may be opened on hover. Specified in milliseconds. Requires the `openOnHover` prop. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| id | string | —sem valor padrão | |
| label | string | —sem valor padrão | Overrides the text label to use when the item is matched during keyboard text navigation. |
| nativeButton | boolean | false | Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `true` if the rendered element is a native button. |
| onClick | ((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | —sem valor padrão | |
| openOnHover | boolean | —sem valor padrão | Whether the menu should also open when the trigger is hovered. |
| render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuSubmenuTriggerState> | —sem valor padrão | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties | ((state: MenuSubmenuTriggerState) => React.CSSProperties | undefined) | —sem valor padrão | Style applied to the element, or a function that returns a style object based on the component's state. |
Estende MenuPrimitive.SubmenuTrigger.Props. Aceita também os atributos padrão de um elemento React (273 não listados).
DropdownMenuSubContent
| Prop | Type | Default | Description |
|---|---|---|---|
| align | Align | 'start' | How to align the popup relative to the specified side. |
| alignOffset | number | OffsetFunction | -3 | Additional offset along the alignment axis in pixels. Also accepts a function that returns the offset to read the dimensions of the anchor and positioner elements, along with its side and alignment. The function takes a `data` object parameter with the following properties: - `data.anchor`: the dimensions of the anchor element with properties `width` and `height`. - `data.positioner`: the dimensions of the positioner element with properties `width` and `height`. - `data.side`: which side of the anchor element the positioner is aligned against. - `data.align`: how the positioner is aligned relative to the specified side. |
| children | React.ReactNode | —sem valor padrão | |
| className | string | ((state: MenuPopupState) => string | undefined) | —sem valor padrão | CSS class applied to the element, or a function that returns a class based on the component's state. |
| finalFocus | boolean | React.RefObject<HTMLElement | null> | ((closeType: InteractionType) => boolean | HTMLElement | null | void) | —sem valor padrão | Determines the element to focus when the menu is closed. - `false`: Do not move focus. - `true`: Move focus based on the default behavior (trigger or previously focused element). - `RefObject`: Move focus to the ref element. - `function`: Called with the interaction type (`mouse`, `touch`, `pen`, or `keyboard`). Return an element to focus, `true` to use the default behavior, or `false`/`undefined` to do nothing. |
| id | string | —sem valor padrão | |
| render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuPopupState> | —sem valor padrão | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| side | Side | 'right' | Which side of the anchor element to align the popup against. May automatically change to avoid collisions. |
| sideOffset | number | OffsetFunction | 0 | Distance between the anchor and the popup in pixels. Also accepts a function that returns the distance to read the dimensions of the anchor and positioner elements, along with its side and alignment. The function takes a `data` object parameter with the following properties: - `data.anchor`: the dimensions of the anchor element with properties `width` and `height`. - `data.positioner`: the dimensions of the positioner element with properties `width` and `height`. - `data.side`: which side of the anchor element the positioner is aligned against. - `data.align`: how the positioner is aligned relative to the specified side. |
| style | React.CSSProperties | ((state: MenuPopupState) => React.CSSProperties | undefined) | —sem valor padrão | Style applied to the element, or a function that returns a style object based on the component's state. |
Estende React.ComponentProps<typeof DropdownMenuContent>. Aceita também os atributos padrão de um elemento React (273 não listados).
DropdownMenuCheckboxItem
| Prop | Type | Default | Description |
|---|---|---|---|
| inset | boolean | —sem valor padrão | |
| checked | boolean | —sem valor padrão | Whether the checkbox item is currently ticked. To render an uncontrolled checkbox item, use the `defaultChecked` prop instead. |
| className | string | ((state: MenuCheckboxItemState) => string | undefined) | —sem valor padrão | CSS class applied to the element, or a function that returns a class based on the component's state. |
| closeOnClick | boolean | false | Whether to close the menu when the item is clicked. |
| defaultChecked | boolean | false | Whether the checkbox item is initially ticked. To render a controlled checkbox item, use the `checked` prop instead. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| id | string | —sem valor padrão | |
| label | string | —sem valor padrão | Overrides the text label to use when the item is matched during keyboard text navigation. |
| nativeButton | boolean | false | Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `true` if the rendered element is a native button. |
| onCheckedChange | ((checked: boolean, eventDetails: MenuCheckboxItem.ChangeEventDetails) => void) | —sem valor padrão | Event handler called when the checkbox item is ticked or unticked. |
| onClick | ((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | —sem valor padrão | The click handler for the menu item. |
| render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuCheckboxItemState> | —sem valor padrão | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties | ((state: MenuCheckboxItemState) => React.CSSProperties | undefined) | —sem valor padrão | Style applied to the element, or a function that returns a style object based on the component's state. |
Estende MenuPrimitive.CheckboxItem.Props. Aceita também os atributos padrão de um elemento React (273 não listados).
DropdownMenuRadioGroup
| Prop | Type | Default | Description |
|---|---|---|---|
| children | React.ReactNode | —sem valor padrão | The content of the component. |
| className | string | ((state: MenuRadioGroupState) => string | undefined) | —sem valor padrão | CSS class applied to the element, or a function that returns a class based on the component's state. |
| defaultValue | any | —sem valor padrão | The uncontrolled value of the radio item that should be initially selected. To render a controlled radio group, use the `value` prop instead. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| onValueChange | ((value: any, eventDetails: MenuRadioGroup.ChangeEventDetails) => void) | —sem valor padrão | Function called when the selected value changes. |
| render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuRadioGroupState> | —sem valor padrão | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties | ((state: MenuRadioGroupState) => React.CSSProperties | undefined) | —sem valor padrão | Style applied to the element, or a function that returns a style object based on the component's state. |
| value | any | —sem valor padrão | The controlled value of the radio item that should be currently selected. To render an uncontrolled radio group, use the `defaultValue` prop instead. |
Estende MenuPrimitive.RadioGroup.Props. Aceita também os atributos padrão de um elemento React (274 não listados).
DropdownMenuRadioItem
| Prop | Type | Default | Description |
|---|---|---|---|
| inset | boolean | —sem valor padrão | |
| value *, obrigatória | any | —sem valor padrão | Value of the radio item. This is the value that will be set in the MenuRadioGroup when the item is selected. |
| className | string | ((state: MenuRadioItemState) => string | undefined) | —sem valor padrão | CSS class applied to the element, or a function that returns a class based on the component's state. |
| closeOnClick | boolean | false | Whether to close the menu when the item is clicked. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| id | string | —sem valor padrão | |
| label | string | —sem valor padrão | Overrides the text label to use when the item is matched during keyboard text navigation. |
| nativeButton | boolean | false | Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `true` if the rendered element is a native button. |
| onClick | ((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | —sem valor padrão | The click handler for the menu item. |
| render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuRadioItemState> | —sem valor padrão | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties | ((state: MenuRadioItemState) => React.CSSProperties | undefined) | —sem valor padrão | Style applied to the element, or a function that returns a style object based on the component's state. |
Estende MenuPrimitive.RadioItem.Props. Aceita também os atributos padrão de um elemento React (273 não listados).
DropdownMenuSeparator
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | ((state: SeparatorState) => string | undefined) | —sem valor padrão | CSS class applied to the element, or a function that returns a class based on the component's state. |
| orientation | Orientation | 'horizontal' | The orientation of the separator. |
| render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SeparatorState> | —sem valor padrão | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties | ((state: SeparatorState) => React.CSSProperties | undefined) | —sem valor padrão | Style applied to the element, or a function that returns a style object based on the component's state. |
Estende MenuPrimitive.Separator.Props. Aceita também os atributos padrão de um elemento React (275 não listados).
DropdownMenuShortcut
Estende React.ComponentProps<'span'>. Aceita também os atributos padrão de um elemento React (280 não listados).
* prop obrigatória.
Composition
Gatilho e conteúdo são irmãos. Grupos são opcionais: eles existem para dar um rótulo a um conjunto de itens, não para conter todo item.
DropdownMenu
- DropdownMenuTrigger
- DropdownMenuContent
- DropdownMenuGroup
- DropdownMenuLabel
- DropdownMenuItem
- DropdownMenuCheckboxItem
- DropdownMenuRadioGroup
- DropdownMenuRadioItem
- DropdownMenuSeparator
- DropdownMenuSub
- DropdownMenuSubTrigger
- DropdownMenuSubContent
- DropdownMenuGroup
Metadata
Notas de acessibilidade
Teclado verificado por teste: ArrowDown abre já com o primeiro item destacado, as setas percorrem os itens pulando os rótulos, Home e End vão às pontas, digitar as primeiras letras encontra um item, ArrowRight abre o submenu e ArrowLeft volta ao item que o abriu, e Escape fecha devolvendo o foco ao gatilho. Leitor de tela verificado por teste: o gatilho declara aria-haspopup="menu" e aria-expanded acompanha o estado, o popup tem papel menu, itens de checkbox e de rádio reportam aria-checked em vez de depender do ícone, e um item desabilitado continua anunciado por aria-disabled recusando a execução sem fechar o menu. Touch verificado em navegador com emulação de toque em viewport de 375px: gatilho e itens medem acima do mínimo de 24x24 da WCAG 2.2 SC 2.5.8 e a escolha por toque funciona. Reduced motion verificado com prefers-reduced-motion: reduce — os tokens de motion colapsam para 1ms e a animação de entrada mede 0.001s.
Classificação
- Layer
- Primitive
- Domínio
- Domain-free (compartilhado)
- Categoria
- overlay
- Status
- Stable
Origem e distribuição
- Fonte
- shadcn registry / dropdown-menu
- Licença
- MIT
- Distribuição
- Interna
Acessibilidade
- ✓Teclado: revisado
- ✓Leitor de tela: revisado
- ✓Touch: revisado
- ✓Reduced motion: revisado
Dependências
- Pacotes
- @base-ui/react
- Ícones
- check, chevron-right
- Construído sobre
- Nenhum
- Usado por
- Menubar