MenuItem API

API reference for the MenuItem component: its props with their token values and defaults, the styled-system prop groups, and forwarded HTML attributes.

Demos

For usage examples, visit the component demo page: MenuItem

Import

import { MenuItem } from '@soroush.tech/design-system/MenuItem'

Props

PropTypeDefaultDescription
valuestring | number-The value this option represents - reported to Select's onChange. Required.
childrenReactNode-The option label.
asElementType'li'The element used for the root node.
disabledbooleanfalseDisables the option - it cannot be highlighted or selected.
selectedbooleanfalseMarks the option as the current selection. Injected by Select.
highlightedbooleanfalseMarks the option as the keyboard-highlighted row. Injected by Select.
multiplebooleanfalseReserves a leading checkmark slot for multi-select menus. Injected by Select.
colorkeyof Theme['palette']'primary'Accent color for hover/selected shading - resolves to theme.palette[color].
textColorkeyof Theme['text']color's mainBase text color of the row - resolves against theme.text. Falls back to the accent color's main.
sizekeyof Theme['sizes']'md'Density token - resolves against theme.sizes.
densebooleanfalseCompact vertical padding, independent of size.
disableGuttersbooleanfalseRemove the left and right padding.
dividerbooleanfalseAdd a 1px bottom border to separate the row.
autoFocusbooleanfalseFocus the row on first mount, and whenever autoFocus flips from false to true.
focusVisibleClassNamestring-Class applied only while the row has keyboard focus - a :focus-visible hook.
onSelect(value: string | number) => void-Fired with value when the option is chosen. Injected by Select.
idstring-DOM id. Select assigns one so the trigger can reference it via aria-activedescendant.

Notes

  • color and textColor are supplied by Select (from its own props), but an item's own value wins - set them on a MenuItem to override the row's accent or text color.
  • Hover and selected shading are derived from theme.palette[color] with hex-suffix opacity, so the row stays on-theme in both color schemes.
  • mousedown is prevented so clicking an option does not blur Select's trigger - the trigger keeps focus for its aria-activedescendant model.

Source code

If this page does not answer your question, have a look at the implementation of the component for more detail.