No Preview

Sorry, but you either have no stories or none are selected somehow.

If the problem persists, check the browser console, or the terminal you've run Storybook from.

Menu

A menu offers a list of choices to the user, such as a set of actions or functions.

usage
import { MenuTrigger, Menu, Item, Section, Divider, MenuTriggerContext, useMenuTriggerContext } from "@sharegate/orbit-ui";
sources
Github

Usage

A menu accepts exactly two children: the element which trigger the opening of the menu and the menu items. A trigger can be any component which accepts a ref and any other props passed from menu.

Default

A default menu.

Editable example

Sections

A menu items can be group by sections.

Editable example

Dividers

A menu items can be separated by dividers.

Editable example

Item icon

A menu item can have icons.

Editable example

Item end icon

A select item can have non standard end icons can be provided to handle special cases like displaying a list of icons. However, think twice before adding end icons, start icons should be your go to.

Editable example

Item description

A menu item can have a single line description.

Editable example

A description can be paired with an icon.

Editable example

A description can also be paired with an avatar

Editable example

Item tooltip

A menu item can have a basic tooltip.

Editable example

Disabled item

A menu item can be disabled.

Editable example

Validation

A menu can display a validation state to communicate to the user whether the current value is valid or invalid. Implement your own validation logic in your app and pass either "valid" or "invalid" to the menu via the validationState prop.

Editable example

Selection

A menu supports multiple selection modes. By default, selection is disabled, however this can be changed by settings the selectionMode property to "single" or "multiple".

When using selection with a <Menu> component wraped inside a <MenuTrigger>, you must handled the selected keys in controlled mode with the selectedKeys property otherwise the selected keys won't be persisted through openings.

Editable example

Custom trigger

A menu trigger can update is appareance based on the isOpen value by using useMenuTriggerContext.

Any trigger would work as long as it accepts a ref and any other props provided by the menu.

Editable example

Disclosure arrow

You can use a disclosure arrow component to hint that activating the button will display additional content.

Editable example

Dynamic items

A menu items can be rendered dynamically.

Editable example

Controlled

The selectedKey and open state can be handled in controlled mode.

Editable example

Opening a modal

A ModalTrigger component won't work with a menu item. Still, it can be done with a custom modal trigger.

Editable example

API

usage
import { MenuTrigger } from "@sharegate/orbit-ui";
NameDescriptionDefault
align
The horizontal alignment of the popup relative to the trigger.
"end""start"
-
allowFlip
Whether or not the popup can flip when it will overflow it's boundary area.
falsetrue
-
allowPreventOverflow
Whether or not the popup position can change to prevent it from being cut off so that it stays visible within its boundary area.
falsetrue
-
children*
React children.
string | number | false | true | ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal
-
closeOnSelect
Whether or not the menu should close when an item is selected.
falsetrue
-
defaultOpen
The initial value of open when in auto controlled mode.
falsetrue
-
direction
The direction the open will open relative to the trigger.
"bottom""top"
-
onOpenChange
Called when the open state change.
(event: SyntheticEvent<Element, Event>, isOpen: boolean) => void
eventReact's original event.
isOpenIndicate if the popup is visible.
-
open
Whether or not to show the popup.
falsetrue
-
zIndex
The z-index of the menu.
number
-
usage
import { Menu } from "@sharegate/orbit-ui";
NameDescriptionDefault
autoFocus
Whether or not the menu should autofocus on render.
numberfalsetrue
-
autoFocusTarget
Default focus target when enabling autofocus.
string
-
children*
React children.
string | number | false | true | ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal
-
defaultSelectedKeys
The initial value of selectedKeys when uncontrolled.
string[]
-
disabled
Whether or not the menu items are disabled.
falsetrue
-
fluid
Whether or not the listbox take up the width of its container.
false | true | ResponsiveValue<boolean>
-
nodes
A collection of nodes to render instead of children. It should only be used if you embed a Menu inside another component.
CollectionNode[]
-
onSelectionChange
Called when the selected keys change.
(event: SyntheticEvent<Element, Event>, keys: string[]) => void
eventReact's original event.
keysThe keys of the selected items..
-
selectedKeys
A controlled set of the selected item keys.
string[]
-
selectionMode
The type of selection that is allowed.
"none""multiple""single"
"none"
validationState
Whether or not the menu should display as "valid" or "invalid".
"valid""invalid"
-

Item

usage
import { Item } from "@sharegate/orbit-ui";
slots
"icon", "text", "description", "end-icon"
NameDescriptionDefault
children
React children.
string | number | false | true | ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal
-
key
A unique key to identify the item.
string
-

Section

usage
import { Section } from "@sharegate/orbit-ui";
NameDescriptionDefault
children*
React children.
string | number | false | true | ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal
-

Divider

usage
import { Divider } from "@sharegate/orbit-ui";
NameDescriptionDefault
orientation
The orientation of the divider.
"horizontal" | "vertical" | ResponsiveValue<"horizontal" | "vertical">
horizontal
usage
import { MenuItem } from "@sharegate/orbit-ui";
NameDescriptionDefault
children*
React children.
string | number | false | true | ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal
-
disabled
Whether or not the item is disabled.
falsetrue
-
item*
Matching collection item.
CollectionItem
-
usage
import { MenuSection } from "@sharegate/orbit-ui";
NameDescriptionDefault
children*
React children.
string | number | false | true | ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal
-
title
The section name.
string
-