Command palette

@yasinsensoy/native

React Native · Components

Menu

An action menu that opens when a button is pressed.

8 exports

Live example

The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.

Preview

Code

import { Menu, Button } from "@yasinsensoy/native";

<Menu
  trigger={<Button variant="outline">Actions</Button>}
  items={[
    { label: "Dosya", items: [
      { label: "Edit", icon: "pencil", shortcut: "Mod+E", onSelect: duzenle },
      { label: "Kopyala", icon: "copy", shortcut: "Mod+C", onSelect: kopyala },
      { label: "Share", icon: "share", disabled: true, tooltip: "Drafts can't be shared" },
    ] },
    "separator",
    { label: "Sil", icon: "delete", tone: "danger", shortcut: "Delete", onSelect: remove },
  ]}
/>

Events

  1. Events appear here when you interact with the preview.

IconButton trigger: its name also shows as a tooltip

Import

import { ContextMenu, Menu } from "@yasinsensoy/native";

ContextMenu

component

A menu that opens on long press (the right-click menu on web). Items are given with the same items array as Menu.

  • Phone: Opens as an action sheet from the bottom.
  • Tablet: Opens where the finger is; flips left/up if it does not fit.
  • Scrolling and normal taps are not affected: the element's own onPress runs, and its own onLongPress is called before the menu.
ContextMenu({ children, items, disabled, longPressDelay, mobileSheet, label, onOpenChange, effect, style, testID, }: ContextMenuProps): JSX.Element

Examples

<ContextMenu items={[{ label: "Open", onSelect: open }, "separator", { label: "Delete", tone: "danger", onSelect: remove }]}>
  <Pressable onPress={open}><FileRow /></Pressable>
</ContextMenu>

Props of the ContextMenu component (same names as on web).

NameTypeDefaultDescription
childrenReactElementThe area to long-press: a single element that takes onLongPress (Pressable, a card, a list row). Props are passed to this element; no extra wrapper is added.
itemsreadonly MenuEntry[]Items, groups and separators; the same as Menu.
disabled?booleanfalseWith true a long press does not open the menu.
longPressDelay?number500Long press duration to open (ms).
onOpenChange?(open: boolean) => voidCalled with the new state when it opens or closes.
mobileSheet?booleantrueOpen from the bottom like an action sheet on narrow screens (phones)? With false it opens next to the trigger.
label?stringScreen reader name of the menu.
effect?EffectPropEffect of the items ("ripple", "glow"…). Defaults to appearance.defaults.menu.effect. See BuiltinEffect.
style?ViewStyleStyle of the menu panel (e.g. { width: 224 }).
testID?stringTest id (menu panel).