# @salmonui/navigation/sidebar-menu API reference

> 11 exported symbols of @salmonui/navigation/sidebar-menu: 1 function, 7 interfaces, 2 types and 1 constant.

Canonical: https://salmonui.dev/docs/reference/navigation/sidebar-menu

```ts
import { … } from '@salmonui/navigation/sidebar-menu';
```

## Functions

### SidebarMenu

Kind: function

Page: https://salmonui.dev/docs/reference/navigation/sidebar-menu/SidebarMenu

```ts
function SidebarMenu(props: SidebarMenuProps): ReactElement;
```

Vertical application navigation: links, submenus, group headings, selection and an icon rail.

## Interfaces

### SidebarMenuExpandedChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/sidebar-menu/SidebarMenuExpandedChangeEvent

```ts
interface SidebarMenuExpandedChangeEvent {
    readonly id: string;
    readonly expanded: boolean;
    readonly source: SidebarMenuSource | 'find';
}
```

Second argument of `onExpandedChange`.

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `id` | `readonly id: string;` |  | The submenu that was toggled. |
| `expanded` | `readonly expanded: boolean;` |  |  |
| `source` | `readonly source: SidebarMenuSource \| 'find';` |  |  |

### SidebarMenuGroup

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/sidebar-menu/SidebarMenuGroup

```ts
interface SidebarMenuGroup {
    readonly type: 'group';
    readonly id: string;
    readonly label: ReactNode;
    readonly textValue?: string | undefined;
    readonly children: readonly SidebarMenuItem[];
}
```

A non-collapsible heading over a list of items.

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `readonly type: 'group';` |  |  |
| `id` | `readonly id: string;` |  |  |
| `label` | `readonly label: ReactNode;` |  |  |
| `textValue` | `readonly textValue?: string \| undefined;` | optional |  |
| `children` | `readonly children: readonly SidebarMenuItem[];` |  |  |

### SidebarMenuItem

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/sidebar-menu/SidebarMenuItem

```ts
interface SidebarMenuItem {
    readonly id: string;
    readonly label: ReactNode;
    readonly textValue?: string | undefined;
    readonly icon?: ReactNode;
    readonly href?: string | undefined;
    readonly children?: readonly SidebarMenuItem[] | undefined;
    readonly disabled?: boolean | undefined;
    readonly badge?: ReactNode;
    readonly type?: 'item' | undefined;
}
```

A link, an action or a submenu.

Members (9):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `id` | `readonly id: string;` |  | Stable, unique id (the selection and expansion key). |
| `label` | `readonly label: ReactNode;` |  |  |
| `textValue` | `readonly textValue?: string \| undefined;` | optional | Plain text of `label` when it is not a string: the rail fallback icon and development messages. |
| `icon` | `readonly icon?: ReactNode;` | optional | Decorative icon (`aria-hidden`); in the collapsed rail it is all that shows. |
| `href` | `readonly href?: string \| undefined;` | optional | Renders a link (through `renderLink` when given). Ignored on an item with `children`. |
| `children` | `readonly children?: readonly SidebarMenuItem[] \| undefined;` | optional | Nested items: the item becomes a disclosure button for a submenu. |
| `disabled` | `readonly disabled?: boolean \| undefined;` | optional |  |
| `badge` | `readonly badge?: ReactNode;` | optional | Trailing content (a count, a status dot); part of the accessible name. |
| `type` | `readonly type?: 'item' \| undefined;` | optional |  |

### SidebarMenuLinkProps

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/sidebar-menu/SidebarMenuLinkProps

```ts
interface SidebarMenuLinkProps {
    readonly href: string;
    readonly className: string;
    readonly 'aria-current'?: 'page' | undefined;
    readonly 'data-sidebar-menu-item': string;
    readonly 'data-sidebar-menu-leaf': '';
    readonly children: ReactNode;
}
```

Props a link item passes to `renderLink`: spread all of them on the link element.

Members (6):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `href` | `readonly href: string;` |  |  |
| `className` | `readonly className: string;` |  |  |
| `aria-current` | `readonly 'aria-current'?: 'page' \| undefined;` | optional |  |
| `data-sidebar-menu-item` | `readonly 'data-sidebar-menu-item': string;` |  | The item id; the menu reads it to select the item on click. |
| `data-sidebar-menu-leaf` | `readonly 'data-sidebar-menu-leaf': '';` |  |  |
| `children` | `readonly children: ReactNode;` |  |  |

### SidebarMenuLocaleText

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/sidebar-menu/SidebarMenuLocaleText

```ts
interface SidebarMenuLocaleText {
    readonly label: string;
}
```

Static texts of `SidebarMenu`. Plain JSON, safe to pass from a server component.

Members (1):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `label` | `readonly label: string;` |  | Accessible name of the `<nav>` landmark (screen readers add "navigation"). |

### SidebarMenuProps

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/sidebar-menu/SidebarMenuProps

```ts
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;
}
```

Members (14):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `items` | `readonly items: readonly SidebarMenuEntry[];` |  | Items, and top-level `{ type: 'group' }` headings with their items. |
| `selected` | `readonly selected?: string \| null \| undefined;` | optional | Selected item id (`null`: none). Controlled; route-driven apps derive it from the location. |
| `defaultSelected` | `readonly defaultSelected?: string \| null \| undefined;` | optional |  |
| `onSelectedChange` | `readonly onSelectedChange?: ((id: string, event: SidebarMenuSelectedChangeEvent) => void) \| undefined;` | optional | A leaf was clicked without modifier keys (a modified click opens a new tab and selects nothing). |
| `expanded` | `readonly expanded?: readonly string[] \| undefined;` | optional | Ids of the open submenus. Controlled. |
| `defaultExpanded` | `readonly defaultExpanded?: readonly string[] \| 'all' \| undefined;` | optional | `'all'` opens every submenu; default: the submenus around the selected item. |
| `onExpandedChange` | `readonly onExpandedChange?: ((expanded: readonly string[], event: SidebarMenuExpandedChangeEvent) => void) \| undefined;` | optional |  |
| `collapsed` | `readonly collapsed?: boolean \| undefined;` | optional | Icon rail: top-level labels hide, links show a tooltip and submenus open as flyouts. Pass the SidebarLayout `collapsed` state. |
| `renderLink` | `readonly renderLink?: ((props: SidebarMenuLinkProps, item: SidebarMenuItem) => ReactNode) \| undefined;` | optional | Renders link items with another element (a router link); spread the props. |
| `onItemClick` | `readonly onItemClick?: ((item: SidebarMenuItem, event: MouseEvent<HTMLElement>) => void) \| undefined;` | optional | Every press on an enabled leaf (modified clicks included): close a mobile drawer here. |
| `landmark` | `readonly landmark?: boolean \| undefined;` | optional | `false` renders a `<div>` instead of the `<nav>` landmark (inside a `SidebarPanel navigation`). Default true. |
| `dividers` | `readonly dividers?: boolean \| undefined;` | optional | Draws a rule between the groups. Default false (groups are separated by space only). |
| `localeText` | `readonly localeText?: Partial<SidebarMenuLocaleText> \| undefined;` | optional |  |
| `ref` | `readonly ref?: Ref<HTMLElement> \| undefined;` | optional | The root `<nav>` (or `<div>`). |

### SidebarMenuSelectedChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/sidebar-menu/SidebarMenuSelectedChangeEvent

```ts
interface SidebarMenuSelectedChangeEvent {
    readonly item: SidebarMenuItem;
    readonly source: SidebarMenuSource;
}
```

Second argument of `onSelectedChange`.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `item` | `readonly item: SidebarMenuItem;` |  |  |
| `source` | `readonly source: SidebarMenuSource;` |  |  |

## Types

### SidebarMenuEntry

Kind: type

Page: https://salmonui.dev/docs/reference/navigation/sidebar-menu/SidebarMenuEntry

```ts
type SidebarMenuEntry = SidebarMenuItem | SidebarMenuGroup;
```

An entry of `items`: groups only at the top level.

### SidebarMenuSource

Kind: type

Page: https://salmonui.dev/docs/reference/navigation/sidebar-menu/SidebarMenuSource

```ts
type SidebarMenuSource = PressSource;
```

Input that caused a change.

## Constants

### SIDEBAR_MENU_DEFAULT_LOCALE_TEXT

Kind: const

Page: https://salmonui.dev/docs/reference/navigation/sidebar-menu/SIDEBAR_MENU_DEFAULT_LOCALE_TEXT

```ts
const SIDEBAR_MENU_DEFAULT_LOCALE_TEXT: SidebarMenuLocaleText;
```
