UNPKG

@wordpress/components

Version:
84 lines 2.26 kB
import type { DropdownMenuProps } from './types'; /** * * The DropdownMenu displays a list of actions (each contained in a MenuItem, * MenuItemsChoice, or MenuGroup) in a compact way. It appears in a Popover * after the user has interacted with an element (a button or icon) or when * they perform a specific action. * * Render a Dropdown Menu with a set of controls: * * ```jsx * import { DropdownMenu } from '@wordpress/components'; * import { * more, * arrowLeft, * arrowRight, * arrowUp, * arrowDown, * } from '@wordpress/icons'; * * const MyDropdownMenu = () => ( * <DropdownMenu * icon={ more } * label="Select a direction" * controls={ [ * { * title: 'Up', * icon: arrowUp, * onClick: () => console.log( 'up' ), * }, * { * title: 'Right', * icon: arrowRight, * onClick: () => console.log( 'right' ), * }, * { * title: 'Down', * icon: arrowDown, * onClick: () => console.log( 'down' ), * }, * { * title: 'Left', * icon: arrowLeft, * onClick: () => console.log( 'left' ), * }, * ] } * /> * ); * ``` * * Alternatively, specify a `children` function which returns elements valid for * use in a DropdownMenu: `MenuItem`, `MenuItemsChoice`, or `MenuGroup`. * * ```jsx * import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components'; * import { more, arrowUp, arrowDown, trash } from '@wordpress/icons'; * * const MyDropdownMenu = () => ( * <DropdownMenu icon={ more } label="Select a direction"> * { ( { onClose } ) => ( * <> * <MenuGroup> * <MenuItem icon={ arrowUp } onClick={ onClose }> * Move Up * </MenuItem> * <MenuItem icon={ arrowDown } onClick={ onClose }> * Move Down * </MenuItem> * </MenuGroup> * <MenuGroup> * <MenuItem icon={ trash } onClick={ onClose }> * Remove * </MenuItem> * </MenuGroup> * </> * ) } * </DropdownMenu> * ); * ``` * */ export declare const DropdownMenu: import("../context").WordPressComponent<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | null, DropdownMenuProps, boolean>; export default DropdownMenu; //# sourceMappingURL=index.d.ts.map