Tree Nav
Overview
A nav list with a tree rail and a spring marker that follows hover and settles on the active link.
This navigation component is intended for interfaces that need a nav list with a tree rail and a spring marker that follows hover and settles on the active link, application shells, and dashboards. Its implementation is provided as editable source so the final behavior and styling stay inside your project.
Technologies
Detected package dependencies: motion.
Installation
Usage
import Link from "next/link"
import { TreeNav } from "@/components/spectrumui/tree-nav"<TreeNav
items={[
{ label: "Overview", href: "/docs" },
{ label: "Installation", href: "/docs/installation" },
{ label: "Tree Nav", href: "/docs/tree-nav", badge: "New" },
]}
activeHref={pathname}
linkComponent={Link}
/>API Reference
TreeNav
Renders a ul of links with a tree rail down the left. One shared background pill and a diamond marker rest on the row whose href matches activeHref, glide to the hovered or focused row on a critically damped spring, and spring back on leave. Motion runs on motion values, so hovering never re-renders the list, and only transform and opacity animate. Row centres are measured, so badges never misplace the marker. Reduced-motion users get instant moves.
| Prop | Type | Default | Description |
|---|---|---|---|
*items | { label: string; href: string; badge?: string; external?: boolean }[] | - | Links to render, top to bottom |
activeHref | string | - | href of the current page; the background and marker rest on this row |
followHover | boolean | true | Glide the background and marker to the hovered row and spring back on leave |
linkComponent | "a" | ComponentType<AnchorHTMLAttributes> | "a" | Element used for links, e.g. Next.js Link |
onSelect | (item: TreeNavItem, event: MouseEvent) => void | - | Fires on click with the item; call preventDefault to handle routing yourself |
className | string | - | Additional classes merged with the list styles |
Use cases
- interfaces that need a nav list with a tree rail and a spring marker that follows hover and settles on the active link
- application shells
- dashboards
Features
- Copy-paste source that remains in your repository
- TypeScript source included with the component
- Tailwind CSS classes editable in the component source
- Animation implemented with Motion
- Spectrum UI registry dependencies: @spectrumui/use-typewriter
Accessibility
- The source includes ARIA attributes or roles; preserve them when customizing the component.
- No reduced-motion marker was detected; add or verify a reduced-motion path before production use.
- Test focus order, keyboard operation, labels, contrast, and screen-reader output in the final application context.
Customization
- Edit the Tailwind utility classes in the copied source to match your spacing, color, and typography tokens.
- Use the documented className surface for local layout adjustments, then edit the source for structural changes.
- Adjust Motion transitions in the source and keep the reduced-motion behavior aligned with the final interaction.
Related components
Tree Nav FAQ
Is Tree Nav free to use in commercial projects?
Yes. The public Tree Nav source is available under the Apache License 2.0, including for commercial use, subject to the LICENSE terms.
How do I install Tree Nav?
Run npx shadcn@latest add @spectrumui/tree-nav. The page also exposes the source for manual installation.
Does Tree Nav require Motion?
Yes. Motion usage was detected in the documented source or registry dependencies for Tree Nav.
Does Tree Nav use shadcn/ui or Radix UI?
No shadcn/ui or Radix UI dependency was detected in the documented Tree Nav source.
Can I use Tree Nav in Next.js?
The documented React source is used in this Next.js application. Keep its use client directive when copying it into the App Router. Install the detected dependencies and verify any application-specific data or image configuration.
What accessibility checks should I run for Tree Nav?
The source includes ARIA markup. Test the finished interface with keyboard and screen-reader workflows.