UNPKG

@payfit/unity-components

Version:

58 lines (57 loc) • 2.41 kB
import { MenuTriggerProps } from 'react-aria-components/Menu'; import { PopoverProps } from 'react-aria-components/Popover'; export interface MenuProps extends Omit<MenuTriggerProps, 'className' | 'style'> { /** Renders all menu content with a denser spacing treatment. */ compact?: boolean; /** Positions the menu popover relative to its trigger. */ placement?: PopoverProps['placement']; /** Adds classes to the Unity popover that wraps the menu content. */ popoverClassName?: string; /** Forwards a ref to the element used to position the popover. */ triggerRef?: PopoverProps['triggerRef']; } /** * Gives people a keyboard-accessible list of actions or navigation choices. * * Compose `Menu` with exactly two children: a `MenuTrigger` and a * `MenuContent`. React Aria manages opening, focus restoration, keyboard * navigation, and dismissal while Unity supplies the menu surface and item * styling. * @param props - Trigger behavior, popover positioning, and menu content. * @param props.children - A `MenuTrigger` followed by a `MenuContent`. * @param props.compact - Renders all menu content with compact spacing. * @param props.defaultOpen - Opens the menu when it first renders. * @param props.placement - Positions the menu relative to its trigger. * @param props.popoverClassName - Adds classes to the menu popover. * @param props.triggerRef - Forwards a ref to the popover positioning element. * @see {@link MenuProps} for all available props. * @see {@link MenuSubmenu} for nested action menus. * @example * ```tsx * import { * Menu, * MenuContent, * MenuTrigger, * RawMenuItem, * } from '@payfit/unity-components' * * export function ActionsMenu() { * return ( * <Menu> * <MenuTrigger>Actions</MenuTrigger> * <MenuContent> * <RawMenuItem onAction={() => console.log('Save')}>Save</RawMenuItem> * <RawMenuItem href="/settings">Settings</RawMenuItem> * </MenuContent> * </Menu> * ) * } * ``` * @remarks * Keep the trigger and content as direct children of `Menu`. Use * `MenuSubmenu` inside `MenuContent` instead of nesting a second `Menu`. */ export declare function Menu({ defaultOpen, compact, children, popoverClassName, triggerRef, placement, ...rest }: MenuProps): import('react/jsx-runtime').JSX.Element; export declare namespace Menu { var displayName: string; }