# components/Tabs (zidane-ui)

Import: `import { … } from 'zidane-ui'`. Source: [ui/src/components/Tabs.tsx](https://github.com/Tahul/zidane/blob/main/ui/src/components/Tabs.tsx).

## Components

### `Tabs`

Component.

Renders a tab list over the selected tab's panel.

```ts
function Tabs(props: TabsProps): Element
```

**Parameters**

- `props` (`TabsProps`): [`TabsProps`](https://zidane.si/docs/reference/ui-components-tabs.md#TabsProps).

**Returns** `Element`

**Props**

- `ariaLabel?` (`string`): Accessible name of the tab list.
- `className?` (`string`): Extra classes on the root element.
- `defaultValue?` (`string`): The first selected tab. Default: the first item.
- `items` (`readonly TabsItem[]`): The tabs, in order.
- `listClassName?` (`string`): Classes on a box around the tab list (absent: no box). A surface that scrolls under its tabs makes it sticky here
  (`sticky top-0` and its own background), so the list stays in view.
- `onChange?` (`(id: string) => void`): Called with the id of the tab picked by click or keyboard.
- `size?` (`'sm' | 'md'`, default `'sm'`): Tab height: `sm` is 24px, `md` is 28px.
- `style?` (`CSSProperties`): Inline styles on the root element.
- `value?` (`string`): The selected tab's id, controlled. Use it with `onChange`.

Source: [ui/src/components/Tabs.tsx:54](https://github.com/Tahul/zidane/blob/main/ui/src/components/Tabs.tsx#L54)

## Interfaces

### `TabsItem`

Interface.

One tab of [`Tabs`](https://zidane.si/docs/reference/ui-components-tabs.md#Tabs).

```ts
interface TabsItem
```

**Properties**

- `content` (`ReactNode`): The panel the tab shows.
- `id` (`string`): Stable id, unique among the items.
- `label` (`ReactNode`): The tab's label.

Source: [ui/src/components/Tabs.tsx:12](https://github.com/Tahul/zidane/blob/main/ui/src/components/Tabs.tsx#L12)

### `TabsProps`

Interface.

Props for [`Tabs`](https://zidane.si/docs/reference/ui-components-tabs.md#Tabs).

```ts
interface TabsProps
```

**Properties**

- `ariaLabel?` (`string`): Accessible name of the tab list.
- `className?` (`string`): Extra classes on the root element.
- `defaultValue?` (`string`): The first selected tab. Default: the first item.
- `items` (`readonly TabsItem[]`): The tabs, in order.
- `listClassName?` (`string`): Classes on a box around the tab list (absent: no box). A surface that scrolls under its tabs makes it sticky here
  (`sticky top-0` and its own background), so the list stays in view.
- `onChange?` (`(id: string) => void`): Called with the id of the tab picked by click or keyboard.
- `size?` (`'sm' | 'md'`, default `'sm'`): Tab height: `sm` is 24px, `md` is 28px.
- `style?` (`CSSProperties`): Inline styles on the root element.
- `value?` (`string`): The selected tab's id, controlled. Use it with `onChange`.

Source: [ui/src/components/Tabs.tsx:22](https://github.com/Tahul/zidane/blob/main/ui/src/components/Tabs.tsx#L22)
