Rail
moco/railFreeComponent
Left-edge section minimap: one tick per heading, active-section highlight, labels on hover. Hidden below 1280px.
Live preview
live · rendered by the registry
Rendered by moco on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://mocoui.site/r/rail.jsonSource
1"use client";23import * as React from "react";4import "./rail.css";5import { useScrollspy, smoothScrollTo } from "@/components/moco/hooks";67export interface Heading {8 id: string;9 text: string;10 level?: number;11}1213export interface RailProps {14 headings: Heading[];15}1617/** Left-edge minimap: one tick per H2. Hidden below 1280px. */18export function Rail({ headings }: RailProps) {19 const ids = React.useMemo(() => headings.map((h) => h.id), [headings]);20 const active = useScrollspy(ids);21 if (!headings.length) return null;2223 return (24 <nav className="moco-rail" aria-label="Sections">25 {headings.map((h, i) => (26 <button27 key={h.id}28 type="button"29 className="moco-rail-item"30 aria-current={i === active}31 aria-label={`Jump to ${h.text}`}32 onClick={() => smoothScrollTo(h.id)}33 >34 <span className="moco-rail-tick" aria-hidden="true" />35 <span className="moco-rail-label" aria-hidden="true">36 {h.text}37 </span>38 </button>39 ))}40 </nav>41 );42}
What it pulls in
Other registry items
Files it writes
More from moco
All 20 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Codecode | moco | Components | Free | 1 dep · 3 files | |
| Comparecompare | moco | Components | Free | no deps · 2 files | |
| Count Upcountup | moco | Components | Free | no deps · 2 files | |
| Covercover | moco | Components | Free | no deps · 2 files | |
| Diagram Kitdiagram | moco | Components | Free | no deps · 2 files | |
| Dot Griddotgrid | moco | Components | Free | no deps · 2 files | |
| Figurefigure | moco | Components | Free | no deps · 2 files | |
| Hookshooks | moco | Components | Free | no deps |
