# NavigationProgress (/docs/navigation-progress)





`NavigationProgress` is the loading bar at the top edge of the viewport that sites like GitHub and YouTube show between pages, in the manner of nprogress and Mantine's `NavigationProgress`. It takes one boolean, `loading`, and invents the progress itself, because no router knows how far along a page load is.

```tsx
import { NavigationProgress } from '@42-central/ui-react/navigation-progress';

<NavigationProgress loading={isNavigating} />
```

## Demo [#demo]

Try each speed. A fast load ends before the delay, so no bar appears. A slow load shows the trickle. In this demo the bar is pinned to the card instead of the viewport.

<Preview align="block" code="`<NavigationProgress loading={loading} color=&#x22;neutral&#x22; />`">
  <SimulatedNavigation />
</Preview>

## Colors [#colors]

`color` takes any palette color through the kit's `data-color` system, as [`Progress`](/docs/progress) does. Use `neutral` for app chrome.

<Preview align="block" code="`<NavigationProgress loading={loading} color=&#x22;blue&#x22; />`">
  <SimulatedNavigation color="blue" />
</Preview>

<Preview align="block" code="`<NavigationProgress loading={loading} color=&#x22;green&#x22; size=&#x22;sm&#x22; />`">
  <SimulatedNavigation color="green" size="sm" />
</Preview>

## Gradient [#gradient]

`variant="gradient"` paints a gradient across the whole bar. The default goes from purple to pink. Pass `gradient` (`from` / `via` / `to` / `dir`) to set your own stops, using the same shape as [`Badge`](/docs/badge) and `Progress`. The gradient spans the full width and the progress reveals it from the left, so the colors stay in place while the bar grows, and the final stop only shows at the end.

<Preview align="block" code="`<NavigationProgress loading={loading} variant=&#x22;gradient&#x22; />`">
  <SimulatedNavigation variant="gradient" size="sm" />
</Preview>

<Preview align="block" code="&#x22;<NavigationProgress\n  loading={loading}\n  variant=\&#x22;gradient\&#x22;\n  gradient={{ from: 'var(--color-cyan-400)', via: 'var(--color-blue-500)', to: 'var(--color-purple-500)' }}\n/>&#x22;">
  <SimulatedNavigation variant="gradient" size="sm" gradient="{ from: 'var(--color-cyan-400)', via: 'var(--color-blue-500)', to: 'var(--color-purple-500)' }" />
</Preview>

## How it moves [#how-it-moves]

* **Delay**: nothing renders until `loading` has stayed `true` for `delay` ms (150 by default), so instant navigations don't flash a bar.
* **Trickle**: the bar starts at a sliver. Every 200ms it closes a tenth of the remaining distance to 90%, so it moves quickly at first, then slows, and never finishes on its own.
* **Complete**: when `loading` turns `false`, the bar runs to 100%, holds briefly, fades out, then snaps back to 0 with its transition off, so it never slides backwards.
* **Re-entry**: if `loading` turns `true` again while the bar is still visible, it continues from where it is. If it had already reached 100%, it restarts from the sliver.
* **Reduced motion**: when the user prefers reduced motion, there is no trickle and no reveal animation. The bar sits at full width while loading and fades when done.

## With TanStack Router [#with-tanstack-router]

Mount it once, in the root layout. Don't add it per route.

```tsx
import { useRouterState } from '@tanstack/react-router';

export function RouteProgress() {
  const loading = useRouterState({ select: (s) => s.isLoading });
  return <NavigationProgress loading={loading} color="neutral" />;
}
```

## Accessibility [#accessibility]

The bar is `aria-hidden`. It repeats information the page change itself gives, and the router or page should announce that change, not the bar. That is why it is not a `role="progressbar"`. For progress that has a real value, use [`Progress`](/docs/progress).

## Styling [#styling]

* `size` sets the thickness. The default is `xs` (2px).
* The bar is `fixed` at the top with `z-index: var(--navigation-progress-z, 1000)`. Set that variable to move it under or over your overlays, or pass `className="absolute"` to pin it to a positioned parent.

## Props [#props]

| Prop                                               | Type                                   | Default                       |
| -------------------------------------------------- | -------------------------------------- | ----------------------------- |
| `loading`                                          | `boolean`                              | (required)                    |
| `delay`                                            | `number` (ms)                          | `150`                         |
| `variant`                                          | `'filled' \| 'gradient'`               | `'filled'`                    |
| `color`                                            | `Color` (ignored for `gradient`)       | kit default solid             |
| `gradient`                                         | `{ from?, via?, to?, dir? }`           | purple-300 → pink-400, `to-r` |
| `size`                                             | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | `'xs'`                        |
| `className` / `classNames.root` / `classNames.bar` | `string`                               |                               |
| `testId`                                           | `string`                               |                               |
