This page as markdown: /section-rail.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

SectionRail

Status: stable

A slim vertical rail of dots, one per section of a long page, that shows where the reader is and jumps to any section. The current section's bar glides as the page scrolls; a shared tooltip names each dot.

Keywords: section rail, scroll spy, scrollspy, dot navigation, page navigation, table of contents, on this page, chapter nav, scroll progress, case study nav

Usage

Use SectionRail beside a long, single-column read — a case study, an essay, a long landing page — so the reader can see which section they are in and jump to another without leaving the text. It follows the scroll by itself (useActiveSection); pass value when the parent already knows the current section.

Best practices

Anatomy

Part Required Description
Rail yes The <nav> landmark: a rounded muted track holding one link per section.
Dot yes A link to #id, drawn as a small dot that grows under the pointer or focus.
Marker yes One primary bar that sits on the current section's dot and glides to the next.
Label yes A shared tooltip that names the hovered or focused dot and travels between dots.

Props

Name Type Default Description
sections readonly { id: string; label: string }[] — The sections, in document order. id is the section element's id (the link goes to #id); label is the tooltip and the link's accessible name.
value string — The current section's id, when the parent decides it. Leave it unset and the rail follows the scroll itself.
onValueChange (id: string) => void — Called with the new id when the reader scrolls into a section or picks one.
offset number 0.35 Where the reading line sits, as a fraction of the viewport from its top. A section becomes current once its top crosses it.
root RefObject<HTMLElement | null> — The element that scrolls, when it is not the window.
side "left" | "right" "left" Which edge of the page the rail sits on. The labels open on the other side, toward the content.
motion "full" | "subtle" | "off" "full" How much motion this component uses: full inherits the app's policy, subtle keeps feedback and drops the marker's glide, off stills it. It can only turn motion down — it never overrides a reader's reduce-motion setting.
aria-label string "Sections" The nav landmark's name. Name it for the page ("Case study sections") when it has other navs.

Tokens used

muted, muted-foreground, foreground, primary, ring, popover, popover-foreground, border-floating

Motion

Accessibility

Related

Examples

Fixed beside a long read

import { SectionRail } from "@sableui/react"

<SectionRail
  aria-label="Case study sections"
  sections={[
    { id: "overview", label: "Overview" },
    { id: "problem", label: "The problem" },
    { id: "process", label: "Process" },
    { id: "outcome", label: "Outcome" },
  ]}
  className="fixed top-1/2 left-6 z-(--z-nav) -translate-y-1/2 max-lg:hidden"
/>

On the right edge

import { SectionRail } from "@sableui/react"

<SectionRail
  side="right"
  sections={[
    { id: "intro", label: "Introduction" },
    { id: "usage", label: "Usage" },
    { id: "api", label: "API" },
  ]}
  className="fixed top-1/2 right-6 z-(--z-nav) -translate-y-1/2 max-lg:hidden"
/>