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

GlidingHighlight

Status: stable

One highlight that travels to the active item, instead of each item toggling its own background. Measured, not assumed, so rows of unequal height stay exact.

Keywords: highlight, active, selection, indicator, menu, list, glide, slide, thumb, hover

Usage

Use GlidingHighlight for a set of items where one is active at a time and the pointer or arrow keys move between them — a menu, an option list, a command palette, a segmented control. It replaces per-item hover:bg-* with a single element that moves.

Best practices

Anatomy

Part Required Description
Container yes Positioning context for the highlight. Each direct child is measured as one item.
Highlight yes The travelling element. aria-hidden, absolutely positioned, invisible until something is active.

Props

Name Type Default Description
active number | null — Index of the item the highlight sits behind, or null for none. Pass hovered ?? selected.
orientation "vertical" | "horizontal" — Deprecated and ignored: the highlight measures both axes, so a horizontal row needs no flag.
onPointerLeave PointerEventHandler (and every other div prop) — The container is a plain div, so its props pass through. For a hover-following list, reset the hovered index here so the highlight returns to the selected row when the pointer leaves.
highlightClassName string — Class for the travelling highlight itself, for changing its fill or radius. The radius defaults to sable-frame-inner, so inside a sable-frame container it nests concentrically; in any other rounded, inset container pass rounded-concentric-<outer>/<inset> here and on the rows. The container's own className styles the list.

Tokens used

accent

Motion

Accessibility

Related

Examples

A hoverable menu, returning home on leave

import { GlidingHighlight } from "@sableui/react"

<GlidingHighlight active={hovered ?? selected} className="sable-frame sable-surface sable-surface-popover sable-frame-popover" onPointerLeave={() => setHovered(null)}>{items.map((item, i) => (<button key={item.id} type="button" className="sable-frame-inner px-2 py-1.5 text-start" onPointerEnter={() => setHovered(i)} onClick={() => setSelected(i)}>{item.label}</button>))}</GlidingHighlight>

Horizontal, as a segmented control

import { GlidingHighlight } from "@sableui/react"

<GlidingHighlight active={tab} className="sable-well flex gap-1 rounded-md p-1" highlightClassName="rounded-concentric-md/1">{tabs.map((t, i) => (<button key={t} type="button" className="rounded-concentric-md/1 px-3 py-1" onClick={() => setTab(i)}>{t}</button>))}</GlidingHighlight>

Keyboard navigation — the case it exists for

import { GlidingHighlight } from "@sableui/react"

<GlidingHighlight active={cursor} onKeyDown={(e) => { if (e.key === "ArrowDown") setCursor((c) => (c + 1) % rows.length) }}>{rows.map((r) => (<div key={r.id} role="option" aria-selected={false}>{r.label}</div>))}</GlidingHighlight>