# Navigation: breadcrumb, pager, stepper

SvBreadcrumb (collapsing trail), SvPagination (page-range with ellipsis, first/last, prev/next) and SvStepper (linear wizard with completed/active/upcoming states). Pure, keyboard-accessible, theme-token driven.

Uses `@svgrid/grid` (MIT). Category: Layout. Live demo: https://svgrid.com/demos/332-app-navigation/

Install: `npm i @svgrid/grid` (Svelte 5).

## About this example

The navigation set of SvGrid UI in Svelte 5: SvBreadcrumb with a trail that collapses in the middle when long, SvPagination with a page range that shows ellipses, first and last and previous and next buttons, and SvStepper for a linear wizard with completed, active and upcoming states. All are keyboard accessible and theme-token driven, and the pagination range math lives in the framework-free paginationRange helper.

SvBreadcrumb, SvPagination and SvStepper - the navigation set. Pure, keyboard-accessible, theme-token driven. Pagination's page-range math lives in the framework-free `paginationRange` helper.

## Imports, features and API used

- Imports: `@svgrid/grid`

## Frequently asked questions

### How does the pagination decide which pages to show?

paginationRange({ page, pageCount, siblings }) returns the page numbers and ellipsis markers around the current page; SvPagination renders it, and you can use the helper for your own pager.

### How does the breadcrumb collapse?

With maxItems set and more items than that, the middle ones fold into an expandable ellipsis so the root and the current page stay visible.

### Can a stepper step be clicked?

Yes when onChange is provided. In linear mode only completed steps and the active one are clickable; otherwise any step is.

## Related documentation

- [SvBreadcrumb](https://svgrid.com/docs/help/ui-components/sv-breadcrumb.md)
- [SvPagination](https://svgrid.com/docs/help/ui-components/sv-pagination.md)
- [SvStepper](https://svgrid.com/docs/help/ui-components/sv-stepper.md)

## Related articles

- [Saved Views - Persist Grid Layout and Filters](https://svgrid.com/blog/saved-views-persist-layout/) - Give users named, switchable snapshots of column order, sorting, filters, and grouping - persisted to localStorage or a server adapter - using SvGrid's createNamedViews API.
- [Avoiding Layout Thrash in Custom Grid Cells](https://svgrid.com/blog/avoiding-layout-thrash-custom-cells/) - Layout thrash from interleaved DOM reads and writes is the most common cause of scroll jank in grids with custom cells - here is how to find it and design your way out of it.
- [Column Resizing and Reordering - Let Users Shape the Grid](https://svgrid.com/blog/column-resizing-and-reordering/) - How to wire drag-to-resize and drag-to-reorder in SvGrid, then persist the layout to localStorage so it survives page reloads.

## Source code (332-app-navigation.svelte)

```svelte
<script lang="ts">
  /**
   * SvBreadcrumb, SvPagination and SvStepper - the navigation set. Pure,
   * keyboard-accessible, theme-token driven. Pagination's page-range math lives
   * in the framework-free `paginationRange` helper.
   */
  import { SvBreadcrumb, SvPagination, SvStepper, type BreadcrumbItem, type StepItem } from '@svgrid/grid'

  const crumbs: BreadcrumbItem[] = [
    { label: 'Home', href: '#' },
    { label: 'Reports', href: '#' },
    { label: 'Q3', href: '#' },
    { label: 'Revenue' },
  ]

  const longTrail: BreadcrumbItem[] = [
    { label: 'Root', href: '#' },
    { label: 'Region', href: '#' },
    { label: 'Country', href: '#' },
    { label: 'City', href: '#' },
    { label: 'Store #1024' },
  ]

  let page = $state(1)

  const steps: StepItem[] = [
    { label: 'Account', description: 'Your details' },
    { label: 'Shipping', description: 'Where to send it' },
    { label: 'Payment', description: 'How you pay', optional: true },
    { label: 'Review', description: 'Confirm & submit' },
  ]
  let step = $state(1)
</script>

<div class="wrap">
  <header>
    <h2>Navigation</h2>
    <p>Breadcrumb trail, pager and stepper - the wayfinding trio for admin apps and Studio-generated screens.</p>
  </header>

  <section>
    <h3>Breadcrumb</h3>
    <SvBreadcrumb items={crumbs} />
    <p class="muted">Collapses the middle on long trails (click the ellipsis to expand):</p>
    <SvBreadcrumb items={longTrail} maxItems={3} />
  </section>

  <section>
    <h3>Pagination</h3>
    <SvPagination {page} pageCount={20} onChange={(p) => (page = p)} showFirstLast />
    <p class="muted">Page {page} of 20.</p>
  </section>

  <section>
    <h3>Stepper</h3>
    <SvStepper {steps} current={step} onChange={(i) => (step = i)} />
    <div class="row">
      <button class="nav" disabled={step === 0} onclick={() => (step = Math.max(0, step - 1))}>Back</button>
      <button class="nav primary" disabled={step === steps.length - 1} onclick={() => (step = Math.min(steps.length - 1, step + 1))}>Next</button>
    </div>
  </section>
</div>

<style>
  .wrap { padding: 20px; max-width: 820px; display: flex; flex-direction: column; gap: 22px; }
  header h2 { margin: 0 0 4px; font-size: 20px; font-weight: 700; }
  header p { margin: 0; color: var(--sg-muted, #64748b); font-size: 13.5px; line-height: 1.5; }
  section h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--sg-muted, #64748b); }
  .row { display: flex; gap: 10px; margin-top: 16px; }
  .muted { color: var(--sg-muted, #94a3b8); font-size: 12.5px; margin: 10px 0 6px; }
  .nav { font: inherit; font-size: 13px; padding: 7px 14px; border: 1px solid var(--sg-border, #cbd5e1); border-radius: 8px; background: var(--sg-input-bg, #fff); color: var(--sg-fg, #0f172a); cursor: pointer; }
  .nav.primary { background: var(--sg-accent, #2563eb); border-color: var(--sg-accent, #2563eb); color: var(--sg-on-accent, #fff); }
  .nav:disabled { opacity: 0.45; cursor: not-allowed; }
</style>
```

[View this example on GitHub](https://github.com/sv-grid/sv-grid/blob/main/examples/src/demos/332-app-navigation.svelte)
