Proximity Nav
A route-aware sidebar navigation whose guide lines stretch toward the pointer, with controlled active state and a navigation-free preview mode.
Installation
npx shadcn@latest add @navui/proximity-navUsage
Provide destination titles and links. Keep the active destination tied to your application's route or controlled state.
import { ProximityNav } from '@/components/navui/proximity-nav'
const items = [
{ title: 'Introduction', href: '/docs/introduction' },
{ title: 'Installation', href: '/docs/installation' },
{ title: 'Components', href: '/docs/components' },
]
export function DocsSidebar() {
return <ProximityNav items={items} label="Documentation" />
}API reference
Custom NavUI navigation component.
| Prop | Type | Default | Description |
|---|---|---|---|
items | readonly ProximityNavItem[] | — | Navigation entries containing a title and destination href. |
activeHref | string | defaultActiveHref / first item | Controlled active destination. When omitted, selection starts at defaultActiveHref or the first item. |
defaultActiveHref | string | First item href | Initial active destination for the navigation-free, uncontrolled preview mode. |
preventNavigation | boolean | false | Prevents route changes and prefetching so clicks can demonstrate active state in an embedded preview. |
onActiveHrefChange | (href: string) => void | — | Called when an item is selected, for controlled state, analytics, or custom navigation behavior. |
label | string | "Navigation" | Accessible label for the nav landmark. |
className | string | — | Classes merged onto the navigation container. |
Accessibility
- Framework-independent native links. Pass activeHref from your router for route tracking. preventNavigation demonstrates local selection. Pointer and focus effects respect reduced motion.