Skip to content
Haze UI

Scroll index

Minimal vertical hairline tick rail that tracks scroll progress and reveals floating section label pills on hover or focus.

pnpm dlx shadcn@latest add @haze/scroll-index
Open preview in a new tab
Livesmall script

When to use

  • An editorial article or scrollable pane needs a right-edge tick-mark rail instead of a full sidebar list
  • Readers want instant visual orientation and smooth section jumping with minimal visual footprint

When not to use

  • All heading labels must stay permanently visible for scanning; use table-of-contents
  • Readers need reading-time estimates and a completion progress bar; use toc-progress

Installation

Add the Haze registry to components.json once, then install Scroll index with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/scroll-index
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
id*string–Unique caller-supplied ID for the index navigation landmark.
items{ id: string; label: string; major?: boolean }[]6 sample sectionsSection anchor IDs and labels; major draws a medium resting tick while minor draws a short hairline.
scrollContainerstring–Optional ID of a scrollable container element; tracks the window when omitted.
labelstring"Section index"Accessible name for the navigation landmark.
side"left" | "right""left"Side of the tick rail where floating section label pills reveal.
offsetnumber28Top threshold in pixels used to determine the currently active section.
classstring–Additional classes on the outer nav element.

Keyboard interactions

TabShiftTab
Enter or leave the vertical tick rail
ArrowUpArrowDown
Move focus along the section ticks and reveal each floating label pill
HomeEnd
Jump focus to the first or last section marker
Enter
Scroll to the target section and move focus to its heading

Accessibility

  • Renders real anchor links inside an ordered list so jumping to sections works without JavaScript.
  • Marks the active section link with aria-current="location" and moves focus to the target heading on click.
  • Falls back to instant scrolling and disables tick animations when prefers-reduced-motion is enabled.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Scroll index" with `npx shadcn@latest add @haze/scroll-index`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import ScrollIndex from "@/components/haze/ui/scroll-index.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/scroll-index.md

  • Customize with real content

    Adapt the Haze scroll-index ui for our product. Replace the demo values of these props with our real content: id, items, scrollContainer, label, side, offset, class. Keep the layout, the heading level rules and these accessibility details: Renders real anchor links inside an ordered list so jumping to sections works without JavaScript. Marks the active section link with aria-current="location" and moves focus to the target heading on click. Falls back to instant scrolling and disables tick animations when prefers-reduced-motion is enabled. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using scroll-index, check it fits: use it when an editorial article or scrollable pane needs a right-edge tick-mark rail instead of a full sidebar list; readers want instant visual orientation and smooth section jumping with minimal visual footprint. Avoid it when all heading labels must stay permanently visible for scanning; use table-of-contents; readers need reading-time estimates and a completion progress bar; use toc-progress. Alternatives: @haze/table-of-contents, @haze/toc-progress.

Dependencies

  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog