Stretch Rail
A sidebar navigation list whose glowing vertical line indicator stretches toward the newly selected item and springs back to size. The leading edge moves quickly while the trailing edge follows more slowly, creating a comet-like elastic effect.


shadcn add · no workarounds · theme neutral (none shipped)Installation
Requires @glint-ui in the registries of your components.json (shadcn adds official directory namespaces automatically).
Usage
import { StretchRail } from "@/components/ui/stretch-rail";export function Example() { return ( <StretchRail items={[ { label: "Home" }, { label: "Inbox", badge: "12" }, { label: "Settings" }, ]} /> );}- Building a sidebar or settings menu where a playful, elastic selection indicator adds personality
- Replacing a static active-state highlight with an animated rail that visually connects the previous and next items
- Showing a vertical list of sections or documentation pages where the current location should be emphasized with motion
- Presenting a navigation list with icons and count badges, such as inbox folders or project tabs
Examples
Sidebar with icons and badges
A navigation sidebar with icons, badges, and a custom indicator color.
import { HomeIcon, InboxIcon, SettingsIcon } from "lucide-react";import { StretchRail } from "@/components/ui/stretch-rail";export function Sidebar() { return ( <aside className="w-60 p-4"> <StretchRail color="#60a5fa" items={[ { label: "Home", icon: <HomeIcon /> }, { label: "Inbox", icon: <InboxIcon />, badge: "8" }, { label: "Settings", icon: <SettingsIcon /> }, ]} /> </aside> );}Controlled selection with onSelect
Start on the third item and react to selection changes.
import { StretchRail } from "@/components/ui/stretch-rail";const sections = ["Overview", "Components", "Themes", "Changelog"];export function DocsNav() { return ( <StretchRail defaultActive={2} items={sections.map((label) => ({ label }))} onSelect={(index) => console.log("selected", sections[index])} /> );}Snappier spring without track
Higher stiffness for a quicker rail and no background track line.
import { StretchRail } from "@/components/ui/stretch-rail";export function QuickNav() { return ( <StretchRail showTrack={false} stiffness={600} items={[{ label: "Dashboard" }, { label: "Reports" }, { label: "Billing" }]} /> );}API reference
Accessibility
- Renders a semantic nav element containing a ul list of items, so screen readers can announce it as a navigation landmark.
- The active button sets aria-current="page" to convey the current location to assistive technology.
- The indicator line and track are marked aria-hidden, so they are decorative and not announced.
- Keyboard support: ArrowDown and ArrowUp move focus between items with wrap-around, Home and End jump to the first and last item.
- Buttons use a visible focus-visible ring (ring-2 ring-ring) for keyboard users.
- Icon color changes alone do not convey state, since aria-current and text color also indicate the active item.
- Consider setting prefers-reduced-motion handling in the consuming app, as the spring animation is not disabled by this component.
Docs written by anthropic:claude-haiku-5-5 from the registry source.
Use with Coding Agent
Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.
Use the "Stretch Rail" component (glint-ui/stretch-rail) from its shadcn registry.1. Install it with: npx shadcn@latest add @glint-ui/stretch-rail2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: items, defaultActive, color, stiffness, showTrack, onSelect, className.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { StretchRail } from "@/components/ui/stretch-rail";export function Example() { return ( <StretchRail items={[ { label: "Home" }, { label: "Inbox", badge: "12" }, { label: "Settings" }, ]} /> );}```Files & dependencies
- registry/ui/stretch-rail.tsx