<!-- AUTO-GENERATED by scripts/generate-docs.mjs — do not edit; edit docs/llm/reference/_fragments/<name>.md and run `pnpm docs:generate`. -->

# Navigation

Use when you move around or structure a flow.

## Index

- [`mega-menu`](#mega-menu) — Horizontal nav with large multi-column panels
- [`nav`](#nav) — Collapsible sidebar navigation with submenus and mini mode
- [`pagination`](#pagination) — Page navigation with ellipsis and prev/next
- [`stepper`](#stepper) — Multi-step wizard with linear/non-linear navigation
- [`tabs`](#tabs) — Tabbed navigation with roving tabindex and arrow keys

---

## mega-menu

Horizontal nav bar where each top-level trigger opens a large multi-column
panel. Opens on hover/focus/click, closes on Escape / outside-click /
focus-leave, with arrow-key navigation between triggers (disclosure-menu ARIA
pattern). Triggers without a panel act as plain links.

```html
<nav data-c42-mega-menu aria-label="Main">
  <ul>
    <li data-c42-mega-menu-item>
      <button data-c42-mega-menu-trigger data-value="products">Products</button>
      <div data-c42-mega-menu-panel>…multi-column content…</div>
    </li>
    <li data-c42-mega-menu-item>
      <a data-c42-mega-menu-trigger href="/pricing">Pricing</a>
    </li>
  </ul>
</nav>
```

```ts
import { MegaMenu } from '@42/core/mega-menu';
const menu = new MegaMenu(root, { openOnHover: true, closeDelay: 150 });
menu.open('products');
```

Keyboard: Left/Right + Home/End move between triggers, ArrowDown opens + enters the panel, Escape closes.
Options: `openOnHover` (default true), `openDelay` (default 0), `closeDelay` (default 150)
Methods: `open(v)`, `toggle(v)`, `closeAll()`, `openValue`
Events: `megamenu:open` → `{ value }`, `megamenu:close` → `{ value }`

---

## nav

Collapsible sidebar navigation (WAI-ARIA disclosure pattern): groups with
`aria-expanded` submenus, an active item (`aria-current="page"`), and an
optional collapsed/mini mode. Reflects `data-state` / `data-active` /
`data-collapsed`.

```html
<nav data-c42-nav aria-label="Main">
  <button data-c42-nav-collapse aria-label="Collapse"></button>
  <ul>
    <li><a data-c42-nav-item href="/" data-value="home">Home</a></li>
    <li data-c42-nav-group>
      <button data-c42-nav-trigger data-value="settings">Settings</button>
      <ul data-c42-nav-submenu>
        <li><a data-c42-nav-item href="/p" data-value="profile">Profile</a></li>
      </ul>
    </li>
  </ul>
</nav>
```

```ts
import { Nav } from '@42/core/nav';
const nav = new Nav(root, { defaultActive: 'profile', accordion: false });
nav.toggleCollapsed();
```

Options: `defaultActive`, `accordion` (default false), `collapsed` (default false)
Methods: `toggleGroup(v)`, `openGroup(v)`, `closeGroup(v)`, `setActive(v)`, `toggleCollapsed()`, `setCollapsed(bool)`
Events: `nav:toggle` → `{ value, open }`, `nav:select` → `{ value }`, `nav:collapse` → `{ collapsed }`

---

## pagination

Page navigation that renders page buttons with ellipsis. Prev/next, `aria-current`.

```html
<nav data-c42-pagination>
  <button data-c42-pagination-prev>Prev</button>
  <div data-c42-pagination-list></div>
  <button data-c42-pagination-next>Next</button>
</nav>
```

```ts
import { Pagination } from '@42/core/pagination';
const p = new Pagination(root, { total: 20, page: 1, siblingCount: 1, boundaryCount: 1 });
p.next();
```

Options: `total` (required), `page`, `siblingCount`, `boundaryCount`
Methods: `setPage(n)`, `next()`, `prev()`
Events: `pagination:change` → `{ page: number }`

---

## stepper

Multi-step wizard with linear/non-linear navigation.

```html
<div data-c42-stepper>
  <div data-c42-stepper-step data-value="1">
    <span data-c42-stepper-indicator></span>
    <button data-c42-stepper-trigger>Step 1</button>
    <div data-c42-stepper-panel>Content for step 1</div>
  </div>
  <div data-c42-stepper-step data-value="2">
    <span data-c42-stepper-indicator></span>
    <button data-c42-stepper-trigger>Step 2</button>
    <div data-c42-stepper-panel>Content for step 2</div>
  </div>
</div>
```

```ts
import { Stepper } from '@42/core/stepper';
const s = new Stepper(root, { linear: true });
s.next(); s.prev(); s.goTo('2');
```

Options: `linear`, `defaultValue`
Events: `stepper:change` → `{ value, index }`

---

## tabs

Tabbed navigation with `tablist`/`tab`/`tabpanel` ARIA, roving tabindex, arrow-key nav.

```html
<div data-c42-tabs>
  <div data-c42-tabs-list>
    <button data-c42-tabs-trigger data-value="a">A</button>
    <button data-c42-tabs-trigger data-value="b">B</button>
  </div>
  <div data-c42-tabs-panel data-value="a">Panel A</div>
  <div data-c42-tabs-panel data-value="b">Panel B</div>
</div>
```

```ts
import { Tabs } from '@42/core/tabs';
new Tabs(root, { orientation: 'horizontal', activationMode: 'automatic', defaultValue: 'a' });
```

Options: `orientation` ('horizontal'|'vertical'), `activationMode` ('automatic'|'manual'), `defaultValue`
Events: `tabs:change` → `{ value: string }`
