Markdown:
Components

MenuGroup

A labeled group for related items inside a MenuList.

Usage

Use inside MenuList, grouping MenuItems.

Svelte
<MenuList>
  <MenuGroup label="Group" {...props}>
    <MenuItem {...props}>Item</MenuItem>
  </MenuGroup>
</MenuList>

Anatomy

The class attribute values represent part names. Other attributes represent their corresponding props.

Svelte
<div class="whole" {...rest} role="group" aria-labelledby={uid}>
  <div id={uid} class="label">{label}</div>
  {children}
</div>

When embedded in MenuList, variant defaults to the menu's and styling falls back to it; local styling wins.

Props

NameTypeDefaultDescription
children*Snippet-Grouped MenuItems; receives the variant as its argument
label*Snippet-Required accessible name rendered in the label part and referenced by aria-labelledby
attachAttachment-Svelte attachment on the root group
elementHTMLDivElement-Bindable root element
stylingSVSClass-Styling override
variantSVSVariantNEUTRALGroup variant

* required. Other HTMLAttributes are passed to <div> via rest props; class is merged onto the root.

Styling

To learn more, see Styling.

Variant Management

No automatic switching.

Default Class Name

svs-menu-group

Behavior

When embedded in MenuList, variant defaults to the menu's and styling falls back to it; local styling wins.

Accessibility

ARIA Roles and Attributes

The component applies these automatically:

  • Group (whole <div>): role="group" and aria-labelledby pointing to the rendered label part.

Provide the required label prop for the group's accessible name; the component renders it and wires it with aria-labelledby.

Exports

Types

TypeScript
interface MenuGroupProps extends Omit<HTMLAttributes<HTMLDivElement>, "children" | "role"> {
  children: Snippet<[string]>; // Snippet<[variant]>; grouped MenuItems
  label: string | Snippet<[string]>; // required accessible name, rendered and referenced by aria-labelledby
  attach?: Attachment<HTMLDivElement>;
  element?: HTMLDivElement; // bindable
  styling?: SVSClass;
  variant?: SVSVariant; // (VARIANT.NEUTRAL)
  // other HTMLAttributes are passed to <div> via ...rest; `class` is merged onto root
  // role and aria-labelledby are component-owned
}
type MenuGroupReqdProps = "children" | "label";
type MenuGroupBindProps = "element";

Others

No additional exports are available.

Examples

The example code uses Tailwind CSS along with SVSClass.

Basic

With Interactive Variant

Preset for Demo
Enter variant as you like