View as Markdown

API reference: @salmonui/navigation/sidebar-menu

SidebarMenuPropsinterface

import type { SidebarMenuProps } from '@salmonui/navigation/sidebar-menu';
interface SidebarMenuProps extends Omit<HTMLAttributes<HTMLElement>, 'children' | 'onSelect' | 'defaultValue'> {
    readonly items: readonly SidebarMenuEntry[];
    readonly selected?: string | null | undefined;
    readonly defaultSelected?: string | null | undefined;
    readonly onSelectedChange?: ((id: string, event: SidebarMenuSelectedChangeEvent) => void) | undefined;
    readonly expanded?: readonly string[] | undefined;
    readonly defaultExpanded?: readonly string[] | 'all' | undefined;
    readonly onExpandedChange?: ((expanded: readonly string[], event: SidebarMenuExpandedChangeEvent) => void) | undefined;
    readonly collapsed?: boolean | undefined;
    readonly renderLink?: ((props: SidebarMenuLinkProps, item: SidebarMenuItem) => ReactNode) | undefined;
    readonly onItemClick?: ((item: SidebarMenuItem, event: MouseEvent<HTMLElement>) => void) | undefined;
    readonly landmark?: boolean | undefined;
    readonly dividers?: boolean | undefined;
    readonly localeText?: Partial<SidebarMenuLocaleText> | undefined;
    readonly ref?: Ref<HTMLElement> | undefined;
}
SidebarMenuProps members (14)
NameSignatureDescription
itemsreadonly items: readonly SidebarMenuEntry[];

Items, and top-level { type: 'group' } headings with their items.

selectedoptionalreadonly selected?: string | null | undefined;

Selected item id (null: none). Controlled; route-driven apps derive it from the location.

defaultSelectedoptionalreadonly defaultSelected?: string | null | undefined;
onSelectedChangeoptionalreadonly onSelectedChange?: ((id: string, event: SidebarMenuSelectedChangeEvent) => void) | undefined;

A leaf was clicked without modifier keys (a modified click opens a new tab and selects nothing).

expandedoptionalreadonly expanded?: readonly string[] | undefined;

Ids of the open submenus. Controlled.

defaultExpandedoptionalreadonly defaultExpanded?: readonly string[] | 'all' | undefined;

'all' opens every submenu; default: the submenus around the selected item.

onExpandedChangeoptionalreadonly onExpandedChange?: ((expanded: readonly string[], event: SidebarMenuExpandedChangeEvent) => void) | undefined;
collapsedoptionalreadonly collapsed?: boolean | undefined;

Icon rail: top-level labels hide, links show a tooltip and submenus open as flyouts. Pass the SidebarLayout collapsed state.

renderLinkoptionalreadonly renderLink?: ((props: SidebarMenuLinkProps, item: SidebarMenuItem) => ReactNode) | undefined;

Renders link items with another element (a router link); spread the props.

onItemClickoptionalreadonly onItemClick?: ((item: SidebarMenuItem, event: MouseEvent<HTMLElement>) => void) | undefined;

Every press on an enabled leaf (modified clicks included): close a mobile drawer here.

landmarkoptionalreadonly landmark?: boolean | undefined;

false renders a <div> instead of the <nav> landmark (inside a SidebarPanel navigation). Default true.

dividersoptionalreadonly dividers?: boolean | undefined;

Draws a rule between the groups. Default false (groups are separated by space only).

localeTextoptionalreadonly localeText?: Partial<SidebarMenuLocaleText> | undefined;
refoptionalreadonly ref?: Ref<HTMLElement> | undefined;

The root <nav> (or <div>).