Rail Nav
A compact motion rail that preserves its line-to-link reveal while supporting anchors, application routes, custom observer targets, and controlled state.
Installation
npx shadcn@latest add @navui/rail-navUsage
Use meaningful anchor destinations and match them to the sections in your page. The reveal effect supplements ordinary links.
Examples
Scroll tracking
A longer document with native anchor links and observed sections.
API reference
Custom NavUI navigation component.
| Prop | Type | Default | Description |
|---|---|---|---|
items | readonly RailNavItem[] | — | Navigation entries with React labels, any link href, optional heading depth, tracking targets, classes, and click handlers. |
value / defaultValue / onValueChange | string / string / (value: string) => void | First item href | Controlled or uncontrolled active navigation value for anchors and application routes. |
expanded / defaultExpanded / onExpandedChange | boolean / boolean / (expanded: boolean) => void | false | Controlled or uncontrolled expansion without changing the original hover and focus animation. |
trackActive / observerOptions | boolean / IntersectionObserverInit | true / tuned viewport margins | Optional section tracking with configurable IntersectionObserver behavior and per-item selectors. |
preventNavigation | boolean | false | Keeps selection local for embedded previews while preserving controlled active state. |
touchToggle | boolean | false | Adds a compact explicit disclosure control for touch-first layouts. |
Accessibility
- Hover or keyboard focus expands the rail. Native anchors, controlled selection, optional scroll tracking, and reduced motion are preserved. Items without depth keep the original indicator lengths. Responsive visibility is left to the consumer.