ContextMenu
A right-click menu attached to a region.
Import
import { ContextMenu } from "@tarve/core";Usage
import { ContextMenu, Text, View } from "@tarve/core";
let open = false;
<ContextMenu
id="canvas-menu"
open={open}
trigger={
<View padding={40}>
<Text>Right-click here</Text>
</View>
}
items={[
{ value: "copy", label: "Copy", shortcut: "Ctrl+C" },
{ value: "paste", label: "Paste", shortcut: "Ctrl+V" },
]}
onOpenChange={(next) => {
open = next;
}}
onSelect={(value) => console.log(value)}
/>Props
| Prop | Type | Default |
|---|---|---|
id required | string | — |
items required | readonly DropdownMenuItem[] | — |
open required | boolean | — |
trigger required | Child | — |
contentStyle | Style | — |
disabled | boolean | false |
label | string | — |
onOpenChange | (open: boolean) => void | — |
onSelect | (value: string) => void | — |
side | PopupSide | "bottom" |
Common props
Shared by every component. See descriptions →
childrenhighlightkeymotionFromonHighlightonPasteonTransitionEndrovingGroupstyleTypes
interface DropdownMenuItem {
value: string;
label: string;
icon?: IconName;
shortcut?: string;
disabled?: boolean;
checked?: boolean;
}type PopupSide = "top" | "right" | "bottom" | "left";