# @salmonui/layout/splitter API reference

> 7 exported symbols of @salmonui/layout/splitter: 2 functions, 4 interfaces and 1 type.

Canonical: https://salmonui.dev/docs/reference/layout/splitter

```ts
import { … } from '@salmonui/layout/splitter';
```

## Functions

### Splitter

Kind: function

Page: https://salmonui.dev/docs/reference/layout/splitter/Splitter

```ts
function Splitter(props: SplitterProps): ReactElement;

namespace Splitter {
    export { SplitterPane as Pane };
}
```

Splitter (`.salmon-splitter`, `data-orientation`).

### SplitterPane

Kind: function

Page: https://salmonui.dev/docs/reference/layout/splitter/SplitterPane

```ts
function SplitterPane(_props: SplitterPaneProps): ReactElement | null;
```

`Splitter.Pane`: a descriptor read by its `Splitter` (it renders through the splitter).

## Interfaces

### SplitterCollapseEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/layout/splitter/SplitterCollapseEvent

```ts
interface SplitterCollapseEvent {
    readonly source: 'keyboard' | 'pointer' | 'api';
    readonly defaultPrevented: boolean;
    preventDefault(): void;
}
```

Second argument of `onCollapsedChange`; `preventDefault()` keeps an uncontrolled pane as it is.

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `source` | `readonly source: 'keyboard' \| 'pointer' \| 'api';` |  |  |
| `defaultPrevented` | `readonly defaultPrevented: boolean;` |  |  |
| `preventDefault` | `preventDefault(): void;` |  |  |

### SplitterLocaleText

Kind: interface

Page: https://salmonui.dev/docs/reference/layout/splitter/SplitterLocaleText

```ts
interface SplitterLocaleText {
    readonly resizePane?: string | undefined;
}
```

Members (1):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `resizePane` | `readonly resizePane?: string \| undefined;` | optional | Separator label. Default `"Resize"`. |

### SplitterPaneProps

Kind: interface

Page: https://salmonui.dev/docs/reference/layout/splitter/SplitterPaneProps

```ts
interface SplitterPaneProps extends Omit<HTMLAttributes<HTMLDivElement>, 'id' | 'content'> {
    readonly id: string;
    readonly children?: ReactNode;
    readonly defaultSize?: SplitterSize | undefined;
    readonly minSize?: SplitterSize | undefined;
    readonly maxSize?: SplitterSize | undefined;
    readonly resizable?: boolean | undefined;
    readonly collapsible?: boolean | undefined;
    readonly collapsed?: boolean | undefined;
    readonly defaultCollapsed?: boolean | undefined;
    readonly onCollapsedChange?: ((collapsed: boolean, event: SplitterCollapseEvent) => void) | undefined;
    readonly onAfterCollapsedChange?: ((collapsed: boolean) => void) | undefined;
    readonly collapsedSize?: SplitterSize | undefined;
}
```

Members (12):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `id` | `readonly id: string;` |  | Stable pane id: the key of `sizes`, the target of `aria-controls`. |
| `children` | `readonly children?: ReactNode;` | optional |  |
| `defaultSize` | `readonly defaultSize?: SplitterSize \| undefined;` | optional | Size when `sizes` has no entry for this pane. |
| `minSize` | `readonly minSize?: SplitterSize \| undefined;` | optional |  |
| `maxSize` | `readonly maxSize?: SplitterSize \| undefined;` | optional |  |
| `resizable` | `readonly resizable?: boolean \| undefined;` | optional | Default true; a separator between two non-resizable panes is not focusable. |
| `collapsible` | `readonly collapsible?: boolean \| undefined;` | optional |  |
| `collapsed` | `readonly collapsed?: boolean \| undefined;` | optional |  |
| `defaultCollapsed` | `readonly defaultCollapsed?: boolean \| undefined;` | optional |  |
| `onCollapsedChange` | `readonly onCollapsedChange?: ((collapsed: boolean, event: SplitterCollapseEvent) => void) \| undefined;` | optional |  |
| `onAfterCollapsedChange` | `readonly onAfterCollapsedChange?: ((collapsed: boolean) => void) \| undefined;` | optional | After a collapse or expand was applied. |
| `collapsedSize` | `readonly collapsedSize?: SplitterSize \| undefined;` | optional | Size while collapsed (a rail). Default 0. |

### SplitterProps

Kind: interface

Page: https://salmonui.dev/docs/reference/layout/splitter/SplitterProps

```ts
interface SplitterProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onResize'> {
    readonly children?: ReactNode;
    readonly panes?: readonly (SplitterPaneProps & {
        readonly content?: ReactNode;
    })[] | undefined;
    readonly orientation?: 'horizontal' | 'vertical' | undefined;
    readonly sizes?: Readonly<Record<string, SplitterSize>> | undefined;
    readonly defaultSizes?: Readonly<Record<string, SplitterSize>> | undefined;
    readonly onSizesChange?: ((sizes: Record<string, SplitterSize>) => void) | undefined;
    readonly onResizeStart?: ((paneIds: readonly [
        string,
        string
    ]) => void) | undefined;
    readonly onResize?: ((sizes: Readonly<Record<string, number>>) => void) | undefined;
    readonly disabled?: boolean | undefined;
    readonly localeText?: SplitterLocaleText | undefined;
    readonly ref?: Ref<HTMLDivElement> | undefined;
}
```

Members (11):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `children` | `readonly children?: ReactNode;` | optional | `Splitter.Pane` children. |
| `panes` | `readonly panes?: readonly (SplitterPaneProps & {     readonly content?: ReactNode; })[] \| undefined;` | optional | Data form of the panes (props of `Splitter.Pane` plus `content`); wins over `children`. |
| `orientation` | `readonly orientation?: 'horizontal' \| 'vertical' \| undefined;` | optional | Default `'horizontal'` (panes side by side). |
| `sizes` | `readonly sizes?: Readonly<Record<string, SplitterSize>> \| undefined;` | optional | Controlled sizes by pane id (panes without a size share the rest). |
| `defaultSizes` | `readonly defaultSizes?: Readonly<Record<string, SplitterSize>> \| undefined;` | optional |  |
| `onSizesChange` | `readonly onSizesChange?: ((sizes: Record<string, SplitterSize>) => void) \| undefined;` | optional | Once at the end of a resize (pointer release or a key press), sizes in each pane's unit. |
| `onResizeStart` | `readonly onResizeStart?: ((paneIds: readonly [     string,     string ]) => void) \| undefined;` | optional |  |
| `onResize` | `readonly onResize?: ((sizes: Readonly<Record<string, number>>) => void) \| undefined;` | optional | Once per animation frame during a drag, px sizes of the two panes; not for React state. |
| `disabled` | `readonly disabled?: boolean \| undefined;` | optional | Separators are inert. |
| `localeText` | `readonly localeText?: SplitterLocaleText \| undefined;` | optional |  |
| `ref` | `readonly ref?: Ref<HTMLDivElement> \| undefined;` | optional | The splitter element. |

## Types

### SplitterSize

Kind: type

Page: https://salmonui.dev/docs/reference/layout/splitter/SplitterSize

```ts
type SplitterSize = number | `${number}px` | `${number}%`;
```

A pane size: px as a number (or `'240px'`), or a percentage of the splitter (`'30%'`).
