MenuItem handbook
v1.3.0 · @snowui-design-system/components
License: Before reading component documentation, source, or npm usage instructions for the first time, read the full LICENSE. Reuse that review for the same task and version. Public API configuration and internal implementation changes have different license implications. All components use the unified runtime package; source rights remain governed by the license.
Overview
Present an option in a list or shortcut panel with optional icon, selection state, and disabled feedback.
When to use it
Use MenuItem for options in Listbox. Use Link or SidebarItem for ordinary navigation; content rows need not all be selectable.
Use
as="item"inside Listbox and give each option a unique value within that list.Disabled prohibits operation; leading / trailing places attachments, closeOnSelect decides whether to close the panel after selection.
The built-in action for deleting a custom option follows LocaleProvider. Query text, option names, and values remain unchanged; the owning Listbox still manages deletion.
Quick start
This example shows the recommended basic composition. See the sections below for more cases and composition limits.
API
See the base component documentation for inherited capabilities not redeclared here. This table lists only named public Props declared by this component.
Usage boundaries and details
Keywords (Props)
Inherit FrameProps (excluding children / tag).
Scene behavior
After clicking the undisabled MenuItem, the snowui-menu-item-select selection intention event will be distributed, and the event carries value and the optional closeOnSelect. MenuItem itself does not decide whether the parent floating layer is closed; floating layer containers such as Popover are processed according to their own default policies, and a single MenuItem closeOnSelect={...} The default value of the container can be overwritten. Listbox is still managed by its own selection protocol to close the behavior.
Layout model
Main layout model: slot host layout. See specs/maintainers/LayoutProtocol.md §12.3.
The root layout of MenuItem is fixed according to the three sections of Leading / Label / Trailing:
The root uses
Frame row singleLineand always enables its internal auto-layout protocol. Passing enableAutoLayout=false does not disable the three-slot MenuItem layout.Plain text or
.snowui-menu-item-labelis a Content / Fill slot, which is responsible for truncation, and must keepmin-width: 0.Direct
as="leading"andas="trailing"children support complex structures; Leading and Trailing hug their contents.When
showCheckis enabled, the default check or delete control occupies Trailing/Hug. When disabled, no check slot or gap remains. A custom direct trailing child hides the default check.Listbox status registration, filter hiding and Popover independent status are MenuItem behavior protocols, which do not change the root three-slot layout.
In Popover (independent Props control)
Compound leading / trailing
In Listbox (context automatic takeover)
Continuous Hover host
In a Listbox or Popover with continuous hover, the host’s single background layer renders MenuItem hover. Standalone items, or hosts with continuousHover={false}, use their own immediate background. An explicit active background persists; hovering an active item layers the host background over it and darkens it.
MenuItem style overlay
Read the full LICENSE first; reuse that review for the same task, version, and scope.
First use public component Props to match the desired appearance, preserving the existing look where possible. If changes are necessary, follow the style selection and override order: use your own class (including Tailwind already in the project) or an instance style. The names below are public overrides actually consumed by source; check their scope and do not modify private DOM. Choose the correct SnowUI token family. External apps need not install SnowUI website utilities.
MenuItem type and status
Required Props: no named required Props.
Bindable Props: this component declares no named two-way binding; handle state updates through public callbacks or its host.
Inheritance statement: Omit<FrameProps, "children" | "tag">. The inheritance ability is subject to the public document of the base class; the fields in Omit have been excluded and cannot be used as they are according to the base class.
The following type declarations are actually referenced by public Props and come from source. A Svelte Snippet denotes a content fragment; ComponentProps denotes the Props of the corresponding component.
ComponentPartsOf
Source: components/src/logic/component-parts.svelte.ts
ConfigurableComponentPartProps
Source: components/src/logic/component-parts.svelte.ts
ComponentPartControlledKey
Source: components/src/logic/component-parts.svelte.ts