Component docs
Loading
"use client";
import { AnchorNav } from "@pixxl-tools/components";| Prop | Type | Default | Description |
|---|---|---|---|
items (required) | readonly AnchorNavItem[] | — | Items to render. |
scrollSpy | AnchorNavScrollSpyOptions | boolean | — | Highlight the section in view (IntersectionObserver + rAF-throttled scroll, page bottom selects the last item). Uncontrolled by default; with value, update it from onValueChange. |
defaultValue | string | — | Initial value when uncontrolled. |
onValueChange | (value: string) => void | — | Called with the new value (only when it changes). |
orientation | "horizontal" | "vertical" | — | Layout and arrow-key axis. |
value | string | — | Current value (controlled); null where it means "nothing selected". |
itemsrequiredreadonly AnchorNavItem[]
Items to render.
scrollSpyAnchorNavScrollSpyOptions | boolean
Highlight the section in view (IntersectionObserver + rAF-throttled scroll, page bottom selects the last item). Uncontrolled by default; with value, update it from onValueChange.
defaultValuestring
Initial value when uncontrolled.
onValueChange(value: string) => void
Called with the new value (only when it changes).
orientation"horizontal" | "vertical"
Layout and arrow-key axis.
valuestring
Current value (controlled); null where it means "nothing selected".
Other props are passed to the root element (HTMLAttributes<HTMLElement>), including className, style, id and aria-* attributes.
const sections = [
{ id: "install", label: "Install", href: "#install" },
{ id: "usage", label: "Usage", href: "#usage" },
];
<AnchorNav items={sections} scrollSpy={{ offset: 80 }} />