# @salmonui/navigation/tabs API reference

> 22 exported symbols of @salmonui/navigation/tabs: 4 functions, 10 interfaces, 7 types and 1 constant.

Canonical: https://salmonui.dev/docs/reference/navigation/tabs

```ts
import { … } from '@salmonui/navigation/tabs';
```

## Functions

### Tab

Kind: function

Page: https://salmonui.dev/docs/reference/navigation/tabs/Tab

```ts
function Tab(props: TabProps): ReactElement;
```

One `role="tab"` button.

### TabList

Kind: function

Page: https://salmonui.dev/docs/reference/navigation/tabs/TabList

```ts
function TabList(props: TabListProps): ReactElement;
```

The `role="tablist"` strip; arrow keys by orientation (mirrored in RTL), Home / End, Delete, Alt+Arrow.

### TabPanel

Kind: function

Page: https://salmonui.dev/docs/reference/navigation/tabs/TabPanel

```ts
function TabPanel(props: TabPanelProps): ReactElement;
```

The panel of one tab (`role="tabpanel"`, labelled by its tab). The element
is always rendered (so `aria-controls` resolves); its content mounts per
`Tabs panelMount`.

### Tabs

Kind: function

Page: https://salmonui.dev/docs/reference/navigation/tabs/Tabs

```ts
function Tabs(props: TabsProps): ReactElement;
```

APG Tabs root. Arranges a `TabList` and its `TabPanel`s in a CSS grid by
`placement` and owns the selection (`value` / `defaultValue` /
`onValueChange`).

## Interfaces

### TabCloseEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tabs/TabCloseEvent

```ts
interface TabCloseEvent {
    readonly value: string;
    readonly source: TabsSource;
}
```

`Tab onClose`: the close button was pressed or Delete was pressed on the focused tab.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `value` | `readonly value: string;` |  |  |
| `source` | `readonly source: TabsSource;` |  |  |

### TabListProps

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tabs/TabListProps

```ts
interface TabListProps extends ListDomProps {
    readonly children?: ReactNode;
    readonly className?: string;
    readonly style?: CSSProperties;
    readonly ref?: Ref<HTMLDivElement>;
}
```

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `children` | `readonly children?: ReactNode;` | optional | `Tab` elements. |
| `className` | `readonly className?: string;` | optional | On the `.salmon-tab-list` wrapper (which also holds the scroll buttons and the overflow menu button). |
| `style` | `readonly style?: CSSProperties;` | optional |  |
| `ref` | `readonly ref?: Ref<HTMLDivElement>;` | optional | The `role="tablist"` element (which also receives `aria-label` and the other DOM props). |

### TabPanelProps

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tabs/TabPanelProps

```ts
interface TabPanelProps extends PanelDomProps {
    readonly value: string;
    readonly children?: ReactNode;
    readonly className?: string;
    readonly style?: CSSProperties;
    readonly ref?: Ref<HTMLDivElement>;
}
```

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `value` | `readonly value: string;` |  | The `Tab value` this panel belongs to. |
| `children` | `readonly children?: ReactNode;` | optional |  |
| `className` | `readonly className?: string;` | optional |  |
| `style` | `readonly style?: CSSProperties;` | optional |  |
| `ref` | `readonly ref?: Ref<HTMLDivElement>;` | optional | The `role="tabpanel"` element. |

### TabProps

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tabs/TabProps

```ts
interface TabProps extends TabDomProps {
    readonly value: string;
    readonly children?: ReactNode;
    readonly icon?: ReactNode;
    readonly iconPlacement?: TabIconPlacement;
    readonly disabled?: boolean | undefined;
    readonly hidden?: boolean | undefined;
    readonly onClose?: ((event: TabCloseEvent) => void) | undefined;
    readonly render?: ((props: TabRenderProps) => ReactElement) | undefined;
    readonly className?: string;
    readonly style?: CSSProperties;
    readonly ref?: Ref<HTMLElement>;
}
```

Members (11):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `value` | `readonly value: string;` |  | Stable key of the tab; matches its `TabPanel value`. |
| `children` | `readonly children?: ReactNode;` | optional | The label. |
| `icon` | `readonly icon?: ReactNode;` | optional | Decorative icon (`aria-hidden`). |
| `iconPlacement` | `readonly iconPlacement?: TabIconPlacement;` | optional | Default `'start'`. |
| `disabled` | `readonly disabled?: boolean \| undefined;` | optional | `aria-disabled="true"`: skipped by arrow keys, not selectable. |
| `hidden` | `readonly hidden?: boolean \| undefined;` | optional | Not shown (the element stays in the DOM with `hidden`). |
| `onClose` | `readonly onClose?: ((event: TabCloseEvent) => void) \| undefined;` | optional | Shows a close button and handles Delete on the focused tab; the application removes the tab. |
| `render` | `readonly render?: ((props: TabRenderProps) => ReactElement) \| undefined;` | optional | Custom element (a router link); receives every computed prop. |
| `className` | `readonly className?: string;` | optional |  |
| `style` | `readonly style?: CSSProperties;` | optional |  |
| `ref` | `readonly ref?: Ref<HTMLElement>;` | optional | The `role="tab"` element. |

### TabsBeforeReorderEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tabs/TabsBeforeReorderEvent

```ts
interface TabsBeforeReorderEvent extends TabsReorderEvent {
    readonly defaultPrevented: boolean;
    preventDefault(): void;
}
```

`onBeforeReorder`: `preventDefault()` cancels the move.

Members (6):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `defaultPrevented` | `readonly defaultPrevented: boolean;` |  |  |
| `preventDefault` | `preventDefault(): void;` |  |  |
| `value` | `value: string;` | inherited |  |
| `fromIndex` | `fromIndex: number;` | inherited |  |
| `toIndex` | `toIndex: number;` | inherited |  |
| `source` | `source: TabsSource;` | inherited |  |

### TabsBeforeValueChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tabs/TabsBeforeValueChangeEvent

```ts
interface TabsBeforeValueChangeEvent extends TabsValueChangeEvent {
    readonly defaultPrevented: boolean;
    preventDefault(): void;
}
```

`onBeforeValueChange`: `preventDefault()` keeps the current tab.

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `defaultPrevented` | `readonly defaultPrevented: boolean;` |  |  |
| `preventDefault` | `preventDefault(): void;` |  |  |
| `value` | `value: string;` | inherited |  |
| `previousValue` | `previousValue: string \| undefined;` | inherited |  |
| `source` | `source: TabsSource;` | inherited |  |

### TabsLocaleText

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tabs/TabsLocaleText

```ts
interface TabsLocaleText {
    readonly scrollBackward: string;
    readonly scrollForward: string;
    readonly moreTabs: string;
    readonly close: string;
}
```

Static texts (`TABS_DEFAULT_LOCALE_TEXT`).

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `scrollBackward` | `readonly scrollBackward: string;` |  |  |
| `scrollForward` | `readonly scrollForward: string;` |  |  |
| `moreTabs` | `readonly moreTabs: string;` |  |  |
| `close` | `readonly close: string;` |  |  |

### TabsProps

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tabs/TabsProps

```ts
interface TabsProps extends RootDomProps {
    readonly children?: ReactNode;
    readonly value?: string | undefined;
    readonly defaultValue?: string;
    readonly onValueChange?: (value: string, event: TabsValueChangeEvent) => void;
    readonly onBeforeValueChange?: (event: TabsBeforeValueChangeEvent) => void;
    readonly placement?: TabsPlacement;
    readonly activation?: TabsActivation;
    readonly panelMount?: TabsPanelMount;
    readonly overflow?: TabsOverflow;
    readonly scrollStep?: number;
    readonly disabled?: boolean;
    readonly reorderable?: boolean;
    readonly onBeforeReorder?: (event: TabsBeforeReorderEvent) => void;
    readonly onReorder?: (event: TabsReorderEvent) => void;
    readonly localeText?: Partial<TabsLocaleText>;
    readonly className?: string;
    readonly style?: CSSProperties;
    readonly ref?: Ref<HTMLDivElement>;
}
```

Members (18):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `children` | `readonly children?: ReactNode;` | optional | `TabList` and `TabPanel` elements (in any order; `placement` arranges them). |
| `value` | `readonly value?: string \| undefined;` | optional | Selected tab value (controlled). |
| `defaultValue` | `readonly defaultValue?: string;` | optional | Initial selected value; without `value` and `defaultValue` the first enabled tab is selected after mount. |
| `onValueChange` | `readonly onValueChange?: (value: string, event: TabsValueChangeEvent) => void;` | optional |  |
| `onBeforeValueChange` | `readonly onBeforeValueChange?: (event: TabsBeforeValueChangeEvent) => void;` | optional | Runs before a selection change; `event.preventDefault()` keeps the current tab. |
| `placement` | `readonly placement?: TabsPlacement;` | optional | Side of the panels the tab list sits on. Default `'top'`; `'start'` / `'end'` make the list vertical. |
| `activation` | `readonly activation?: TabsActivation;` | optional | Default `'automatic'` (selection follows focus). |
| `panelMount` | `readonly panelMount?: TabsPanelMount;` | optional | Default `'lazy'`. |
| `overflow` | `readonly overflow?: TabsOverflow;` | optional | Default `'scroll'`. |
| `scrollStep` | `readonly scrollStep?: number;` | optional | Pixels per scroll button press (`overflow="scroll"`). Default 100. |
| `disabled` | `readonly disabled?: boolean;` | optional | Disables every tab. |
| `reorderable` | `readonly reorderable?: boolean;` | optional | Tabs can be reordered by pointer drag and Alt+Arrow keys; the application moves the tab in `onReorder`. |
| `onBeforeReorder` | `readonly onBeforeReorder?: (event: TabsBeforeReorderEvent) => void;` | optional |  |
| `onReorder` | `readonly onReorder?: (event: TabsReorderEvent) => void;` | optional |  |
| `localeText` | `readonly localeText?: Partial<TabsLocaleText>;` | optional |  |
| `className` | `readonly className?: string;` | optional |  |
| `style` | `readonly style?: CSSProperties;` | optional |  |
| `ref` | `readonly ref?: Ref<HTMLDivElement>;` | optional | The root element. |

### TabsReorderEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tabs/TabsReorderEvent

```ts
interface TabsReorderEvent {
    readonly value: string;
    readonly fromIndex: number;
    readonly toIndex: number;
    readonly source: TabsSource;
}
```

`onReorder`: the application moves the tab from `fromIndex` to `toIndex` (indices among the `Tab` elements).

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `value` | `readonly value: string;` |  |  |
| `fromIndex` | `readonly fromIndex: number;` |  |  |
| `toIndex` | `readonly toIndex: number;` |  |  |
| `source` | `readonly source: TabsSource;` |  |  |

### TabsValueChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tabs/TabsValueChangeEvent

```ts
interface TabsValueChangeEvent {
    readonly value: string;
    readonly previousValue: string | undefined;
    readonly source: TabsSource;
}
```

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

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `value` | `readonly value: string;` |  |  |
| `previousValue` | `readonly previousValue: string \| undefined;` |  |  |
| `source` | `readonly source: TabsSource;` |  |  |

## Types

### TabIconPlacement

Kind: type

Page: https://salmonui.dev/docs/reference/navigation/tabs/TabIconPlacement

```ts
type TabIconPlacement = 'start' | 'end' | 'top' | 'bottom';
```

Where a `Tab` icon sits relative to the label.

### TabRenderProps

Kind: type

Page: https://salmonui.dev/docs/reference/navigation/tabs/TabRenderProps

```ts
type TabRenderProps = HTMLAttributes<HTMLElement> & {
    readonly ref: (element: HTMLElement | null) => void;
    readonly role: 'tab';
    readonly id: string;
    readonly tabIndex: number;
    readonly 'data-value': string;
} & {
    readonly [attribute: `data-${string}`]: string | undefined;
};
```

Props passed to a custom tab element (`render`): spread them all.

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `id` | `id: string;` | inherited |  |
| `tabIndex` | `tabIndex: number;` | inherited |  |
| `role` | `role: "tab";` | inherited |  |
| `ref` | `ref: (element: HTMLElement \| null) => void;` | inherited |  |
| `data-value` | `data-value: string;` | inherited |  |

### TabsActivation

Kind: type

Page: https://salmonui.dev/docs/reference/navigation/tabs/TabsActivation

```ts
type TabsActivation = 'automatic' | 'manual';
```

`automatic`: a tab is selected when it receives focus (APG default); `manual`: Enter / Space selects.

### TabsOverflow

Kind: type

Page: https://salmonui.dev/docs/reference/navigation/tabs/TabsOverflow

```ts
type TabsOverflow = 'scroll' | 'menu';
```

`scroll`: the list scrolls with scroll buttons; `menu`: tabs that do not fit move into a "More tabs" menu.

### TabsPanelMount

Kind: type

Page: https://salmonui.dev/docs/reference/navigation/tabs/TabsPanelMount

```ts
type TabsPanelMount = 'lazy' | 'active' | 'eager';
```

`lazy`: a panel mounts on its first selection and stays; `active`: only the selected panel; `eager`: every panel, also on the server.

### TabsPlacement

Kind: type

Page: https://salmonui.dev/docs/reference/navigation/tabs/TabsPlacement

```ts
type TabsPlacement = 'top' | 'bottom' | 'start' | 'end';
```

Side of the panels the tab list sits on; `start` / `end` are logical and imply a vertical list.

### TabsSource

Kind: type

Page: https://salmonui.dev/docs/reference/navigation/tabs/TabsSource

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

Input that caused a change.

## Constants

### TABS_DEFAULT_LOCALE_TEXT

Kind: const

Page: https://salmonui.dev/docs/reference/navigation/tabs/TABS_DEFAULT_LOCALE_TEXT

```ts
const TABS_DEFAULT_LOCALE_TEXT: TabsLocaleText;
```
