MenuGroup
A labeled group for related items inside a MenuList.
Usage
Use inside MenuList, grouping MenuItems.
<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.
<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
| Name | Type | Default | Description |
|---|---|---|---|
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 |
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 <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"andaria-labelledbypointing 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
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.