# @salmonui/navigation/sidebar-layout API reference

> 17 exported symbols of @salmonui/navigation/sidebar-layout: 4 functions, 8 interfaces, 4 types and 1 constant.

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

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

## Functions

### SidebarLayout

Kind: function

Page: https://salmonui.dev/docs/reference/navigation/sidebar-layout/SidebarLayout

```ts
function SidebarLayout(props: SidebarLayoutProps): ReactElement;
```

### SidebarMain

Kind: function

Page: https://salmonui.dev/docs/reference/navigation/sidebar-layout/SidebarMain

```ts
function SidebarMain(props: SidebarMainProps): ReactElement;
```

The content beside the panel; its inline size follows the panel track.

### SidebarPanel

Kind: function

Page: https://salmonui.dev/docs/reference/navigation/sidebar-layout/SidebarPanel

```ts
function SidebarPanel(props: SidebarPanelProps): ReactElement;
```

The panel: `<aside>` or `<nav>` with an accessible name (`aria-label` defaults to `localeText.panel`),
painted by the theme's `sidebar` surface (`data-salmon-surface="sidebar"`, overridable).

### SidebarTrigger

Kind: function

Page: https://salmonui.dev/docs/reference/navigation/sidebar-layout/SidebarTrigger

```ts
function SidebarTrigger(props: SidebarTriggerProps): ReactElement;
```

A button that toggles the panel (or its rail) with `aria-expanded` and `aria-controls`.

## Interfaces

### SidebarBeforeOpenChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/sidebar-layout/SidebarBeforeOpenChangeEvent

```ts
interface SidebarBeforeOpenChangeEvent extends SidebarOpenChangeEvent {
    readonly open: boolean;
    readonly defaultPrevented: boolean;
    preventDefault(): void;
}
```

Argument of `onBeforeOpenChange`; `preventDefault()` keeps the current state.

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `open` | `readonly open: boolean;` |  | The proposed state. |
| `defaultPrevented` | `readonly defaultPrevented: boolean;` |  |  |
| `preventDefault` | `preventDefault(): void;` |  |  |
| `source` | `source: SidebarSource;` | inherited |  |
| `reason` | `reason: SidebarOpenChangeReason;` | inherited |  |

### SidebarCollapsedChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/sidebar-layout/SidebarCollapsedChangeEvent

```ts
interface SidebarCollapsedChangeEvent {
    readonly source: SidebarSource;
    readonly reason: 'trigger';
}
```

Second argument of `onCollapsedChange`.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `source` | `readonly source: SidebarSource;` |  |  |
| `reason` | `readonly reason: 'trigger';` |  |  |

### SidebarLayoutLocaleText

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/sidebar-layout/SidebarLayoutLocaleText

```ts
interface SidebarLayoutLocaleText {
    readonly panel: string;
    readonly toggle: string;
    readonly collapse: string;
}
```

Static texts (accessible names). Plain JSON, safe to pass from a server component.

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `panel` | `readonly panel: string;` |  | Default accessible name of `SidebarPanel`. |
| `toggle` | `readonly toggle: string;` |  | Name of an icon-only `SidebarTrigger` (`action="open"`). |
| `collapse` | `readonly collapse: string;` |  | Name of an icon-only `SidebarTrigger action="collapse"`. |

### SidebarLayoutProps

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/sidebar-layout/SidebarLayoutProps

```ts
interface SidebarLayoutProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
    children?: ReactNode;
    ref?: Ref<HTMLDivElement> | undefined;
    mode?: SidebarPresentation | undefined;
    collapseBelow?: number | string | undefined;
    side?: 'start' | 'end' | undefined;
    size?: number | string | undefined;
    railSize?: number | string | undefined;
    open?: boolean | undefined;
    defaultOpen?: boolean | undefined;
    onOpenChange?: ((open: boolean, event: SidebarOpenChangeEvent) => void) | undefined;
    onBeforeOpenChange?: ((event: SidebarBeforeOpenChangeEvent) => void) | undefined;
    collapsed?: boolean | undefined;
    defaultCollapsed?: boolean | undefined;
    onCollapsedChange?: ((collapsed: boolean, event: SidebarCollapsedChangeEvent) => void) | undefined;
    closeOnOutsidePress?: boolean | undefined;
    localeText?: Partial<SidebarLayoutLocaleText> | undefined;
}
```

Members (16):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `children` | `children?: ReactNode;` | optional |  |
| `ref` | `ref?: Ref<HTMLDivElement> \| undefined;` | optional | The root `<div>`. |
| `mode` | `mode?: SidebarPresentation \| undefined;` | optional | `'push'` (default): the main content shrinks. `'overlay'`: the panel covers the main content. |
| `collapseBelow` | `collapseBelow?: number \| string \| undefined;` | optional | Push mode only: below this width the layout uses the overlay presentation. A number is the layout's own (container) inline size in px; a string is a media query that matches when the layout is narrow (`'(max-width: 767px)'`). |
| `side` | `side?: 'start' \| 'end' \| undefined;` | optional | Logical side of the panel (flips under `dir="rtl"`). Default `'start'`. |
| `size` | `size?: number \| string \| undefined;` | optional | Panel inline size (CSS length or px). Default `16rem`. |
| `railSize` | `railSize?: number \| string \| undefined;` | optional | Inline size of the collapsed rail (CSS length or px). Default `56px`. |
| `open` | `open?: boolean \| undefined;` | optional |  |
| `defaultOpen` | `defaultOpen?: boolean \| undefined;` | optional | Default `true` in push mode, `false` in overlay mode. |
| `onOpenChange` | `onOpenChange?: ((open: boolean, event: SidebarOpenChangeEvent) => void) \| undefined;` | optional |  |
| `onBeforeOpenChange` | `onBeforeOpenChange?: ((event: SidebarBeforeOpenChangeEvent) => void) \| undefined;` | optional | Synchronous; `event.preventDefault()` cancels the change. |
| `collapsed` | `collapsed?: boolean \| undefined;` | optional | Icon rail: the open panel shrinks to `railSize` (push presentation). |
| `defaultCollapsed` | `defaultCollapsed?: boolean \| undefined;` | optional |  |
| `onCollapsedChange` | `onCollapsedChange?: ((collapsed: boolean, event: SidebarCollapsedChangeEvent) => void) \| undefined;` | optional |  |
| `closeOnOutsidePress` | `closeOnOutsidePress?: boolean \| undefined;` | optional | Push presentation: a press outside the panel and its triggers closes it. Default false. |
| `localeText` | `localeText?: Partial<SidebarLayoutLocaleText> \| undefined;` | optional |  |

### SidebarMainProps

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/sidebar-layout/SidebarMainProps

```ts
interface SidebarMainProps extends HTMLAttributes<HTMLDivElement> {
    children?: ReactNode;
    ref?: Ref<HTMLDivElement> | undefined;
    render?: ((props: SidebarRenderProps) => ReactElement) | undefined;
}
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `children` | `children?: ReactNode;` | optional |  |
| `ref` | `ref?: Ref<HTMLDivElement> \| undefined;` | optional |  |
| `render` | `render?: ((props: SidebarRenderProps) => ReactElement) \| undefined;` | optional | Renders another element (`<main>`) with the computed props. |

### SidebarOpenChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/sidebar-layout/SidebarOpenChangeEvent

```ts
interface SidebarOpenChangeEvent {
    readonly source: SidebarSource;
    readonly reason: SidebarOpenChangeReason;
}
```

Second argument of `onOpenChange` (frozen in development).

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `source` | `readonly source: SidebarSource;` |  |  |
| `reason` | `readonly reason: SidebarOpenChangeReason;` |  |  |

### SidebarPanelProps

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/sidebar-layout/SidebarPanelProps

```ts
interface SidebarPanelProps extends Omit<HTMLAttributes<HTMLElement>, 'id'> {
    children?: ReactNode;
    navigation?: boolean | undefined;
    ref?: Ref<HTMLElement> | undefined;
}
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `children` | `children?: ReactNode;` | optional |  |
| `navigation` | `navigation?: boolean \| undefined;` | optional | Renders `<nav>` (navigation landmark) instead of `<aside>` (complementary). |
| `ref` | `ref?: Ref<HTMLElement> \| undefined;` | optional |  |

### SidebarTriggerProps

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/sidebar-layout/SidebarTriggerProps

```ts
interface SidebarTriggerProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {
    children?: ReactNode;
    action?: 'open' | 'collapse' | undefined;
    icon?: ReactNode;
    ref?: Ref<HTMLButtonElement> | undefined;
    render?: ((props: SidebarRenderProps) => ReactElement) | undefined;
}
```

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `children` | `children?: ReactNode;` | optional |  |
| `action` | `action?: 'open' \| 'collapse' \| undefined;` | optional | `'open'` (default) toggles the panel; `'collapse'` toggles the icon rail. |
| `icon` | `icon?: ReactNode;` | optional | Replaces the built-in icon (decorative). |
| `ref` | `ref?: Ref<HTMLButtonElement> \| undefined;` | optional |  |
| `render` | `render?: ((props: SidebarRenderProps) => ReactElement) \| undefined;` | optional | Renders another element with the computed props (ARIA and handlers included). |

## Types

### SidebarOpenChangeReason

Kind: type

Page: https://salmonui.dev/docs/reference/navigation/sidebar-layout/SidebarOpenChangeReason

```ts
type SidebarOpenChangeReason = 'trigger' | 'outside' | 'escape' | 'breakpoint';
```

Why the panel opened or closed: a `SidebarTrigger`, a press outside, Escape (overlay) or a `collapseBelow` switch.

### SidebarPresentation

Kind: type

Page: https://salmonui.dev/docs/reference/navigation/sidebar-layout/SidebarPresentation

```ts
type SidebarPresentation = 'push' | 'overlay';
```

### SidebarRenderProps

Kind: type

Page: https://salmonui.dev/docs/reference/navigation/sidebar-layout/SidebarRenderProps

```ts
type SidebarRenderProps = HTMLAttributes<HTMLElement> & {
    ref?: Ref<never> | undefined;
    [dataAttribute: `data-${string}`]: string | number | undefined;
};
```

Props `render` receives; spread all of them onto the returned element.

Members (1):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `ref` | `ref?: Ref<never>;` | optional, inherited |  |

### SidebarSource

Kind: type

Page: https://salmonui.dev/docs/reference/navigation/sidebar-layout/SidebarSource

```ts
type SidebarSource = 'pointer' | 'keyboard' | 'touch' | 'api';
```

Input that caused a change.

## Constants

### SIDEBAR_LAYOUT_DEFAULT_LOCALE_TEXT

Kind: const

Page: https://salmonui.dev/docs/reference/navigation/sidebar-layout/SIDEBAR_LAYOUT_DEFAULT_LOCALE_TEXT

```ts
const SIDEBAR_LAYOUT_DEFAULT_LOCALE_TEXT: SidebarLayoutLocaleText;
```
