Track highlight
Shared fluid hover, keyboard-focus, and selection highlight for custom lists and groups, with CSS anchors and a measured fallback.
Examples
Sliding selection
Use a relative, isolated container with data-track="slide", mark its controls with data-track-item, and place TrackHighlight after them. data-active="true" identifies the selection. Hover or keyboard focus previews another item; leaving returns to the selection. Keep hit areas touching for continuous hover: the highlight follows actual targets, without nearest-item detection or gap clicks.
Composition
Custom hover or selection track
Set data-track="hover" or "slide" on the container; mark the selected item with data-active.
- <div>
- items with data-track-item
- <Button />
- <TrackHighlight />
- items with data-track-item
Installation
The Control UI source installs this primitive from src/registry/sources/control-ui/extensions/track-highlight.tsx.
Dependencies
src/registry/sources/control-ui/extensions/create-track-highlight.tsSupportsrc/registry/sources/control-ui/extensions/supports-anchor-transitions.tsSupportRaw code
Primary installed source
Knobs
Typed custom properties the recipe paints with. Set one on the root — style, a utility class, or a skin — and every slot inherits it.
--cui-track-highlight-* · 6 knobsHow the cascade resolves--cui-track-highlight-radius<length-percentage>var(--radius-popup-item)--cui-track-highlight-background<color>var(--card)--cui-track-highlight-hover-background<color>color-mix(in oklab, var(--card) 92%, var(--foreground) 8%)--cui-track-highlight-ring-color<color>oklch(from var(--foreground) l c h / 0.05)--cui-track-highlight-shadow*var(--shadow-sm)--cui-track-highlight-transition-duration<time>var(--duration-fast)