# Navigation

Tabs, steppers and pagination. Exact props: `widgets-get-component-props`.

---

## DTabs and DTabs.Tab

`options` describes the tabs; each `DTabs.Tab` holds the panel of one tab, matched by `tab`:

```tsx
const options = [
  { tab: 'movements', label: t('account.movements') },
  { tab: 'details', label: t('account.details') },
];

<DTabs options={options} defaultSelected="movements" ariaLabel={t('account.sections')}>
  <DTabs.Tab tab="movements"><Movements /></DTabs.Tab>
  <DTabs.Tab tab="details"><Details /></DTabs.Tab>
</DTabs>
```

| Prop | Use |
|------|-----|
| `options` | Required. Each option has `tab` (the id) and `label`, and optionally `disabled` |
| `defaultSelected` | The id of the initially selected tab; without it, the first enabled tab. Ignored inside `DTabs.Provider` |
| `onChange(option)` | Receives the selected option |
| `variant` | `underline` (default), `tabs`, `pills` or `toggle-button-group` |
| `vertical` | Vertical tab bar |
| `ariaLabel`, `ariaLabelledBy` | Accessible name of the tab bar |

### DTabs.Provider: panels outside the tab bar

When the tab bar and the panels live in different places (the bar in a header, the panels in another column), wrap both in `DTabs.Provider`, which owns the selected tab:

```tsx
<DTabs.Provider defaultSelected="movements">
  <header>
    <DTabs options={options} ariaLabel={t('account.sections')} />
  </header>
  <main>
    <DTabs.Tab tab="movements"><Movements /></DTabs.Tab>
    <DTabs.Tab tab="details"><Details /></DTabs.Tab>
  </main>
</DTabs.Provider>
```

Inside the tabs, `useTabContext` exposes `isSelected` (`modyo://docs/widgets/components-hooks`).

## DStepper

Shows the steps of a flow. `options` lists the steps (`label`, `value`, optionally `description`) and `currentStep` is the `value` of the current one:

```tsx
const steps = [
  { label: t('transfer.steps.destination'), value: 1 },
  { label: t('transfer.steps.amount'), value: 2 },
  { label: t('transfer.steps.confirm'), value: 3 },
];

<DStepper options={steps} currentStep={step} />
```

`DStepper` renders the mobile layout below `breakpoint` (`lg` by default) and the desktop layout from it up; `DStepperDesktop` and `DStepperMobile` render only one of them. `vertical` and `completed` apply to the desktop layout.

## DPaginator

```tsx
<DPaginator current={page} total={totalPages} onPageChange={setPage} />
```

`current`, `total` (number of pages) and `onPageChange(page)` are required. Keep `page` in the component's state and put it in the query key of the list, so each page is its own cache entry (`modyo://docs/widgets/patterns-tanstack-query`).

---

## Common mistakes

| Wrong | Right |
|-------|-------|
| `<DTabOption>` as a component | `DTabOption` is the type of each item of `options`; panels are `DTabs.Tab` |
| Options without `tab` | Each option needs `tab` (id) and `label` |
| `current` taken only from the API response | `current` comes from state, so the page changes immediately |
