UNPKG

@carbon/react

Version:

React components for the Carbon Design System

72 lines (71 loc) 2.53 kB
/** * Copyright IBM Corp. 2023, 2025 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ import React, { ReactNode, RefObject } from 'react'; export interface MenuProps extends React.HTMLAttributes<HTMLUListElement> { /** * The ref of the containing element, used for positioning and alignment of the menu */ containerRef?: RefObject<HTMLDivElement | null>; /** * A collection of MenuItems to be rendered within this Menu. */ children?: ReactNode; /** * Additional CSS class names. */ className?: string; /** * A label describing the Menu. */ label: string; /** * Specify how the menu should align with the button element */ menuAlignment?: string; /** * @deprecated Menus now always support both icons as well as selectable items and nesting. * The mode of this menu. Defaults to full. * `full` supports nesting and selectable menu items, but no icons. * `basic` supports icons but no nesting or selectable menu items. * * **This prop is not intended for use and will be set by the respective implementation (like useContextMenu, MenuButton, and ComboButton).** */ mode?: 'full' | 'basic'; /** * Provide an optional function to be called when the Menu should be closed, * including if the Menu is blurred, the user presses escape, or the Menu is * a submenu and the user presses ArrowLeft. */ onClose?: () => void; /** * Provide an optional function to be called when the Menu is opened. */ onOpen?: () => void; /** * Whether the Menu is open or not. */ open?: boolean; /** * Specify the size of the Menu. */ size?: 'xs' | 'sm' | 'md' | 'lg'; /** * Specify a DOM node where the Menu should be rendered in. Defaults to document.body. */ target?: Element; /** * Specify the x position of the Menu. Either pass a single number or an array with two numbers describing your activator's boundaries ([x1, x2]) */ x?: number | [number, number]; /** * Specify the y position of the Menu. Either pass a single number or an array with two numbers describing your activator's boundaries ([y1, y2]) */ y?: number | [number, number]; legacyAutoalign?: boolean; } declare const Menu: React.ForwardRefExoticComponent<MenuProps & React.RefAttributes<HTMLUListElement>>; export { Menu };