- Getting Started
- The Basics
- Concepts
- SuperNative
-
EDGE Components
- Introduction
- Activity Indicator
- Badge
- Bottom Navigation
- Bottom Sheet
- Button
- Button Group
- Canvas
- Carousel
- Checkbox
- Chip
- Column
- Divider
- Gesture Area
- Icon
- Icons
- Image
- Layout & Styling
- List
- Menus
- Modal
- Pressable
- Progress Bar
- Radio Group
- Row
- Scroll View
- Select
- Shapes
- Side Navigation
- Slider
- Spacer
- Stack
- Tab Row
- Text
- Text Input
- Toggle
- Top Bar
- Virtual List
- Web View
- Plugins
- Testing
- Architecture
You're viewing pre-release documentation — version 4.x is in beta
Features, APIs and behaviour may change before the stable release. View the stable version (3.x)
Menus
Overview#
A menu is a tap-to-open dropdown (SwiftUI Menu / Compose DropdownMenu) attached to a component. It isn't a
standalone element — you build a list of actions and attach it with an attribute:
:menuon a button or pressable — tapping opens the menu instead of firing@press.:trailing-menuon a list item — opens from the row's trailing edge.
All three share one item model: an array of NavAction, the same builder used for
nav-bar menus.
Building the items#
Each item is a NavAction. Give it an id, an icon, a label, and a press() handler; insert
NavAction::divider() for a separator and ->destructive() to tint an item as dangerous:
use Native\Mobile\Edge\Layouts\Builders\NavAction; $menu = [ NavAction::make('export_pdf')->icon('doc')->label('Export as PDF')->press('exportPdf'), NavAction::make('export_csv')->icon('tablecells')->label('Export as CSV')->press('exportCsv'), NavAction::divider(), NavAction::make('delete')->icon('trash')->label('Delete')->press('delete')->destructive(),];
Build the array in your component (in render(), mount(), or a helper) and pass it to the attribute.
Attaching to a button or pressable#
{{-- Button: the menu replaces @press --}}<native:button label="Export" :menu="$menu" /> {{-- Pressable: any content becomes the tap target --}}<native:pressable :menu="$menu"> <native:icon name="ellipsis" /></native:pressable>
When :menu is set, tapping opens the menu — it shadows the element's own @press.
Attaching to a list item#
Use :trailing-menu to open a menu from a row's trailing edge — a common pattern for per-row actions:
@foreach ($conversations as $chat) <native:list-item headline="{{ $chat->name }}" supporting="{{ $chat->preview }}" :trailing-menu="$rowMenu" />@endforeach
Item reference#
The menu-relevant NavAction methods:
make(string $id)— create an item with a unique idicon(?string $name = null, ios:, android:)— a leading iconlabel(string)— the row textpress(string $method)— the component method to call when chosenurl(string)— navigate to a URL instead of calling a methoddestructive(bool = true)— tint the item as destructiveNavAction::divider()— a separator row
See the NavAction builder for the full list.
in no time