# MenuGroup A labeled group for related items inside a `MenuList`. ## Usage Use inside `MenuList`, grouping `MenuItem`s. ```svelte Item ``` ## Anatomy The `class` attribute values represent part names. Other attributes represent their corresponding props. ```svelte
{label}
{children}
``` When embedded in `MenuList`, `variant` defaults to the menu's and `styling` falls back to it; local `styling` wins. ## Props | Name | Type | Default | Description | |---|---|---|---| | `children*` | `Snippet` | - | Grouped `MenuItem`s; receives the variant as its argument | | `label*` | `Snippet` | - | Required accessible name rendered in the `label` part and referenced by `aria-labelledby` | | `attach` | `Attachment` | - | Svelte attachment on the root group | | `element` | `HTMLDivElement` | - | Bindable root element | | `styling` | `SVSClass` | - | Styling override | | `variant` | `SVSVariant` | `NEUTRAL` | Group variant | `*` required. Other `HTMLAttributes` are passed to `
` via rest props; `class` is merged onto the root. ## Styling To learn more, see [Styling](/docs/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` `
`): `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 ```ts interface MenuGroupProps extends Omit, "children" | "role"> { children: Snippet<[string]>; // Snippet<[variant]>; grouped MenuItems label: string | Snippet<[string]>; // required accessible name, rendered and referenced by aria-labelledby attach?: Attachment; element?: HTMLDivElement; // bindable styling?: SVSClass; variant?: SVSVariant; // (VARIANT.NEUTRAL) // other HTMLAttributes are passed to
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 **Code** ```svelte src=MenuGroupBasic.svelte New file Duplicate Profile Sign out ``` ### With Interactive Variant **Code** ```svelte src=MenuGroupPract.svelte New file Duplicate Profile Sign out ```