# Bottom navigation

A bottom tab bar for phones with four or five top destinations and badges.

- Family: navigation
- Import: `import { BottomNav } from "@senvenli/react/navigation";`
- Page: https://design.senvenli.com/docs/components/bottom-nav
- JSON: https://design.senvenli.com/docs/components/bottom-nav.json

## Example: A phone's tab bar

Shown under 768px only: on a wider window the frame stays empty.

```tsx
import { Text } from "@senvenli/react/display";
import { BottomNav } from "@senvenli/react/navigation";

export default function Example() {
  return (
    // Demo frame only: `contain-layout` pins the BottomNav to this box. In an app it sits at the bottom of the viewport.
    <div className="relative mx-auto h-80 max-w-96 overflow-hidden rounded-ds-large border border-ds-border p-ds-200 contain-layout">
      <Text tone="subtle">The BottomNav shows under 768px.</Text>
      <BottomNav
        currentKey="orders"
        items={[
          { id: "home", label: "Home", icon: "house", href: "#" },
          { id: "orders", label: "Orders", icon: "shopping-cart", href: "#", badge: { value: 4 } },
          { id: "invoices", label: "Invoices", icon: "receipt", href: "#" },
          { id: "inbox", label: "Inbox", icon: "inbox", href: "#", badge: { value: 2, tone: "danger" } },
          { id: "more", label: "More", icon: "ellipsis", href: "#" },
        ]}
      />
    </div>
  );
}
```

## Guidelines

### When to use it

- The main navigation of an app on phones.

### Use something else when

- [sidebar](https://design.senvenli.com/docs/components/sidebar.md): There are more than five destinations or a wide screen.
- [tabs](https://design.senvenli.com/docs/components/tabs.md): The views belong to one page, not the whole app.

## Accessibility

Built in:

- Hides while the on-screen keyboard is open.
- Badges are announced with their item.

You provide:

- Short labels.

## API reference

### BottomNav

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| items | `readonly BottomNavItem[]` |  | yes | Four or five top destinations. |
| currentKey | `string` |  | no |  |
| aria-label | `string` |  | no | Names the navigation landmark; "Main menu" by default. |

### Tokens it reads

`--ds-background-neutral-pressed`, `--ds-border`, `--ds-border-focused`, `--ds-icon-brand`, `--ds-radius-medium`, `--ds-shadow-overflow`, `--ds-space-025`, `--ds-space-050`, `--ds-space-075`, `--ds-space-100`, `--ds-space-150`, `--ds-surface-overlay`, `--ds-text`, `--ds-text-subtle`

## Related

- [sidebar](https://design.senvenli.com/docs/components/sidebar.md)
