Lynx

Menu

A component that provides a list of choices or actions that users can take.

Engine ≥ 3.9<overlay>
Loading Lynx example…

Installation

npx @seed-design/cli@latest add ui:menu

Usage

Menu consists of Root, Trigger, Content, and Group. MenuContent handles native overlay, position calculation, display lifetime, and vertical scrolling of long lists together.

import { ActionButton } from "@seed-design/lynx-react";

import {
  MenuContent,
  MenuGroup,
  MenuGroupLabel,
  MenuItem,
  MenuRoot,
  MenuTrigger,
} from "@/components/ui/menu";

export function App() {
  return (
    <MenuRoot>
      <MenuTrigger>
        <ActionButton variant="neutralSolid">Open</ActionButton>
      </MenuTrigger>
      <MenuContent>
        <MenuGroup>
          <MenuGroupLabel>Actions</MenuGroupLabel>
          <MenuItem label="Item 1" />
          <MenuItem label="Item 2" />
        </MenuGroup>
        <MenuGroup>
          <MenuItem label="Item 3" />
        </MenuGroup>
      </MenuContent>
    </MenuRoot>
  );
}
  • MenuRoot manages the open state and position.
  • MenuTrigger opens a closed Menu by tapping.
  • MenuAnchor provides only the position reference point. Control the open state with open and onOpenChange.
  • MenuContent renders the overlay and scrollable menu list. Do not add a separate Positioner or ScrollArea to children.
  • MenuGroup and MenuGroupLabel group related items and display the title.
  • MenuItem assembles label, optional description, prefixIcon, suffixIcon into one item.

Props

Prop

Type

open?boolean | undefined
defaultOpen?boolean | undefined
onOpenChange?((open: boolean, details: MenuOpenChangeDetails) => void) | undefined
disabled?boolean | undefined
placement?Placement | undefined
gutter?number | undefined
overflowPadding?number | undefined
matchReferenceWidth?boolean | undefined
size?"small" | "medium" | "responsive" | undefined
style?CSSProperties | undefined
children?React.ReactNode
className?string | undefined

Prop

Type

disabled?boolean | undefined
style?CSSProperties | undefined
children?React.ReactNode
className?string | undefined
bindtap?EventHandler<BaseTouchEvent<Target>> | undefined
main-thread:bindtap?EventHandler<BaseTouchEvent<Element>> | undefined

Prop

Type

style?CSSProperties | undefined
children?React.ReactNode
className?string | undefined

Prop

Type

style?CSSProperties | undefined
children?React.ReactNode
className?string | undefined

Prop

Type

style?CSSProperties | undefined
children?React.ReactNode
className?string | undefined

Prop

Type

style?CSSProperties | undefined
children?React.ReactNode
className?string | undefined

Prop

Type

labelReact.ReactNode
description?React.ReactNode
prefixIcon?React.ReactElement<LynxIconElementProps, string | React.JSXElementConstructor<any>> | undefined
suffixIcon?React.ReactElement<LynxIconElementProps, string | React.JSXElementConstructor<any>> | undefined
className?string | undefined
bindtap?EventHandler<BaseTouchEvent<Target>> | undefined
main-thread:bindtap?EventHandler<BaseTouchEvent<Element>> | undefined
disabled?boolean | undefined
style?CSSProperties | undefined

Examples

Trigger

Tapping MenuTrigger opens a closed Menu. Tapping MenuItem or the outer area closes it.

Loading Lynx example…

Size

Set the Menu size with size. The default is "medium". "responsive" changes to "small" or "medium" based on the current screen width.

Loading Lynx example…

With Description

Pass additional description of the item in MenuItem's description.

Loading Lynx example…

Tone

Mark actions requiring caution, such as deletion, with MenuItem's tone="critical".

Loading Lynx example…

Disabled Items

disabled items do not execute bindtap when tapped and do not close the Menu.

Loading Lynx example…

Placement

Position the Menu at 12 directions around the reference element using MenuRoot's placement. The default is "bottom". If there's insufficient space at the screen edge, the native runtime flips it or moves it within the boundary.

Loading Lynx example…

Anchor

MenuAnchor only sets the Menu position and does not open or close it by tapping. You can control the state with open and onOpenChange as in this example.

Loading Lynx example…

While the native overlay is open, you cannot tap the Switch outside the Anchor. This example shows the flow of opening with the Switch when the Menu is closed and closing by selecting an item. Control to ignore taps outside the overlay is implemented by filtering details.reason === "interactOutside" in onOpenChange.

Match Width

Using matchReferenceWidth makes the Menu width equal to the Trigger or Anchor width.

Loading Lynx example…

onOpenChange details

The details parameter, the second argument of onOpenChange, contains the reason for the state change and the native event.

  • Open: "trigger"
  • Close: "trigger", "interactOutside", "itemClick"
  • When native overlay requests closing: "dismiss"
Loading Lynx example…

Differences from Web Version

Lynx Menu renders on top of native overlay. It does not support HTML DOM, asChild, keyboard focus, typeahead, or ESC key closing. Therefore, it does not provide escapeKeyDown and cascadeDismiss reasons. For keyboard accessibility needed at the screen and app level, check with the host's native accessibility flow.

ItemWebLynx
Trigger compositionSupports asChildUses native Trigger wrapping children
Position and listDOM positioner and scroll areaMenuContent handles native overlay, position, and scroll together
External interactionDOM pointer and keyboardOuter tap is interactOutside, native dismissal is dismiss
KeyboardSupports ESC, focus, typeaheadNot supported
Control while Anchor is openCan continue composing outer controlsFullscreen overlay blocks taps outside Anchor

Table of contents