ContextMenu
Na linha da tabela
import { ContextMenu } from '@rivocode/ui'Quando usar
O menu do botão direito.
O conteúdo e o mesmo do Menu: use MenuContent, MenuItem, MenuGroup e
MenuSeparator dentro dele. Só o gatilho muda, porque aqui quem abre e a área
inteira, e não um botão.
Nunca deixe uma ação existir só aqui. Quem navega por teclado depende da tecla de menu, que nem todo teclado tem, e num navegador de celular não ha botão direito. Ele acelera o que já esta em outro lugar, no menu de ações da linha, por exemplo.
No React Native o mesmo caso existe, e o gesto muda: o Menu do
@rivocode/ui-native abre no toque longo da área que você passar como
children. A seção do fim desta pagina diz como.
<ContextMenu>
<ContextMenuTrigger className="rounded-md border border-dashed p-6">
Clique com o botao direito
</ContextMenuTrigger>
<MenuContent>
<MenuItem>Baixar PDF</MenuItem>
<MenuItem>Duplicar</MenuItem>
<MenuSeparator />
<MenuItem tone="danger">Cancelar nota</MenuItem>
</MenuContent>
</ContextMenu>
No React Native
Vira Menu, e não peça nova: o menu do botão direito é, no celular, o toque longo, e quem abre a folha de ações já é o Menu. Passe a área alvo como children dele — o que no web é o ContextMenuTrigger — e ela chama onOpenChange(true) no toque longo, com triggerClassName para o layout que os filhos exigem. Quem navega por leitor de tela entra pela mesma porta: a área expõe a ação longpress, que o VoiceOver e o TalkBack oferecem no menu de ações, então o gesto nunca é o único caminho.
API
| Prop | Tipo |
|---|---|
actionsRef0.4.0A ref to imperative actions. | RefObject<MenuRootActions | null> |
closeParentOnEsc0.4.0When in a submenu, determines whether pressing the Escape key closes the entire menu, or only the current child menu. | boolean |
defaultOpen0.4.0Whether the menu is initially open. | boolean |
disabled0.4.0Whether the component should ignore user interaction. | boolean |
highlightItemOnHover0.4.0Whether moving the pointer over items should highlight them. | boolean |
loopFocus0.4.0Whether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys. | boolean |
onOpenChange0.4.0Event handler called when the menu is opened or closed. | ((open: boolean, eventDetails: ContextMenuRootChangeEventDetails) => void) |
onOpenChangeComplete0.4.0Event handler called after any animations complete when the menu is opened or closed. | ((open: boolean) => void) |
open0.4.0Whether the menu is currently open. | boolean |
orientation0.4.0The visual orientation of the menu. | MenuRootOrientation |