Skip to content

No.291 · Navigation

Ruler Index

A vertical table of contents drawn as a ruler: long ticks for sections, short ticks between, the current section lit.

The prompt

Copy this text

Automatic copying is unavailable. Copy the selected text using your device’s copy command.

The design brief behind this component — reuse it to regenerate, remix, or explain it.

Design an "on this page" index that looks like the edge of a ruler. Right-align a column of ticks: for each section a 28px major tick with a mono uppercase label to its left, and four short 12px minor ticks between consecutive sections at even spacing, so the whole thing reads as a graduated scale. Scrollspy: an IntersectionObserver (rootMargin −30% / −55%) picks the section in view. The active major tick lengthens 1.5×, turns frost blue with a soft glow, and its label is shown in cream; inactive labels are hidden (opacity 0, shifted 6px). Hovering the ruler reveals every label; hovering a single tick lengthens it. Clicking or pressing Enter on a tick scrolls to its section. Labels stay visible on devices without hover. All movement uses cubic-bezier(0.16,1,0.3,1) at 220–300ms. It's a real <nav aria-label="On this page"> with links and aria-current="location" on the active one. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Scroll updates the lit tick; hover reveals labels; click/Enter jumps to the section. Motion: Tick and label transitions 220–300ms ease-out-expo. Accessibility: A labelled <nav> of real anchor links with aria-current=location; focus-visible ring on each tick; labels always visible without hover. Reduced motion shortens transitions. Responsive behavior: Fixed 10rem column; place it in a sticky sidebar. Touch: All labels are shown when hover isn't available. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.

Notes

Interaction
Scroll updates the lit tick; hover reveals labels; click/Enter jumps to the section.
Motion
Tick and label transitions 220–300ms ease-out-expo.
Accessibility
A labelled <nav> of real anchor links with aria-current=location; focus-visible ring on each tick; labels always visible without hover. Reduced motion shortens transitions.
Responsive
Fixed 10rem column; place it in a sticky sidebar.
On touch
All labels are shown when hover isn't available.