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-nav

Usage

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.

Rail Nav properties
PropTypeDefaultDescription
itemsreadonly RailNavItem[]—Navigation entries with React labels, any link href, optional heading depth, tracking targets, classes, and click handlers.
value / defaultValue / onValueChangestring / string / (value: string) => voidFirst item hrefControlled or uncontrolled active navigation value for anchors and application routes.
expanded / defaultExpanded / onExpandedChangeboolean / boolean / (expanded: boolean) => voidfalseControlled or uncontrolled expansion without changing the original hover and focus animation.
trackActive / observerOptionsboolean / IntersectionObserverInittrue / tuned viewport marginsOptional section tracking with configurable IntersectionObserver behavior and per-item selectors.
preventNavigationbooleanfalseKeeps selection local for embedded previews while preserving controlled active state.
touchTogglebooleanfalseAdds 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.