Menu

11.2.10

A menu displays a list of choices on a temporary surface.

Demo

NamnTypBeskrivning

anchorEl

"undefined" | Element | PopoverVirtualElementRef to the element used as the Popover anchor.

anchorOrigin

PopoverOriginThe point on the anchor where the popover's anchorEl will attach to.

anchorPosition

PopoverPositionPosition of the menu popup.

anchorReference

PopoverReferenceDetermines which anchor prop to refer to when setting the position of the popover.

bottomContent

ReactNodeContent to be rendered at the bottom of the menu, below the menu items.

bottomSheetMaxHeight

MaxHeightHeight limit for the BottomSheet variant. Use with caution, as it can affect accessibility text zoom. The preferred value is calc(100% - NN px) to ensure content is not cut off during zoom.

children

ReactNodeThe children of the component.

customAttribute

{ attribute: string; value: string | number }Used for tests. Clickable and requested subcomponents will be suffixed with "-[ComponentName]".

elevation

numberThe elevation of the popover.

id

stringA unique ID for the menu, used for WAI-ARIA and other purposes.

lang

"sv" | "en"Language used for internal translations.

LeftButtonProps

ButtonBaseOwnProps & CommonProps & Omit & LinkPropsProps for the left bottom button, including a label.

maxWidth

numberWidth limit, does not apply for mobile bottom sheets.

onClose

() => voidCallback fired when the component requests to be closed.

open *

booleanControls whether the menu is open or closed.

popoverMaxHeight

MaxHeightHeight limit for the Popover variant. Note: Must include the unit (e.g., px, rem).

RightButtonProps

ButtonBaseOwnProps & CommonProps & Omit & LinkPropsProps for the right bottom button, including a label.

role

AriaRoleChanges the aria role of the <MenuList> component.

showButtons

booleanIf true, the popup will display close and done buttons.

showCloseButton

booleanIf true, the popup will display a close button in the top right corner.

showTitle

booleanIf true, the title will be displayed at the top.

subheading

stringA caption shown under the title.

sx

SxPropsThe system prop that allows defining system overrides as well as additional CSS styles.

title *

stringMandatory title used for accessibility labels. If you want the title to be visible as well, use the showTitle prop.

topContent

ReactNodeOptional content to be rendered at the top of the menu.

transformOrigin

PopoverOriginThe point on the popover which will attach to the anchor's origin.

variant

"popover" | "automatic" | "bottomsheet"The variant of the menu popup to display. The "automatic" option will render based on the current device width.

Installation

npm install @sj-ab/component-library.ui.menu

Länkar

Tillgänglighet

WAI-ARIA

Komponenten Menu strävar efter att följa designmönstret "Menu" från WAI-ARIA Authoring practices guide.

Menu använder bland annat:

  • role="menu" för att markera menyområdet

  • aria-label för att sätta ett namn på menyn

  • role="menuitem" för varje valbart alternativ i menyn

  • role="menuitemcheckbox" för menyalternativ med kryssruta eller switch

  • role="menuitemradio" för menyalternativ med radioknapp

  • aria-selected="true" för menyalternativ som är valda

  • role="dialog" på Bottom Sheet-dialogen när Menu visas på små skärmar.

Återfokusering

När Menu stängs så flyttas fokus tillbaka till knappen som öppnade menyn. Detta sker automatiskt i komponenten och behöver oftast inte hanteras av utvecklare.

Tangentbordsinteraktioner

  • Enter
    Välj markerat menyval
  • Pil ned
    Gå till nästa menyval
  • Pil upp
    Gå till föregående menyval

Change log

Statistik

  • Importer av Menu

    24
  • Repos med Menu

    55%
  • Senaste installerade version av Menu

    11.2.10
  • Äldsta installerade version av Menu

    2.2.0