Skip to content

Menu Component

The MenuComponent provides native menu support for bottom sheets, context menus, and dropdown menus.

Basic Info

Description

This component enables native menu interactions including bottom sheets, context menus, and dropdown menus.

How to Use

1. Web Implementation

javascript
import { useMenu } from '@bagisto-native/react';

const MenuComponent = () => {
    const { showMenu } = useMenu();

    const handleShowMenu = () => {
        showMenu({
            type: "bottomSheet", // or "contextMenu", "dropdown"
            title: "Product Options",
            items: [
                { id: "add", label: "Add to Cart", icon: "cart" },
                { id: "wishlist", label: "Add to Wishlist", icon: "heart" },
                { id: "share", label: "Share", icon: "share" }
            ],
            onSelect: (item) => {
                console.log("Selected:", item.id);
                // Handle menu item selection
            },
            onDismiss: () => {
                console.log("Menu dismissed");
            }
        });
    };

    return <button onClick={handleShowMenu}>Show Menu</button>;
};

2. Native Side

kotlin
navigator.registerBridgeComponent("menu", MenuComponent(this))

API Reference

PropertyTypeRequiredDescription
typeStringYes"bottomSheet", "contextMenu", or "dropdown"
titleStringNoMenu title
itemsArrayYesMenu items with id, label, icon
onSelectFunctionYesSelection callback
onDismissFunctionNoDismiss callback

Bottom Sheet

  • Full-width sliding panel from bottom
  • Best for primary actions
  • Supports icons and descriptions

Context Menu

  • Appears at touch location
  • Best for secondary actions
  • Compact display
  • Anchored to specific view
  • Best for filtered selections
  • Appears below anchor point

Next Steps

Released under the MIT License.