Takeoff Anchor
ASecurityUse `Anchor` for navigation between sections of the same page. It renders a `<nav>` landmark with a list of links; the Spar `Anchor` primitive watches the scroll container and marks the link of the section in view with `aria-current="location"`. A link press scrolls smoothly to its section, moves focus there and writes the hash. **When to use:** Long docs, settings, policy or detail pages with a side table of contents. Not this — use `takeoff-tabs` to switch panels in place, `takeoff-sidebar`...
- 3 stars
- 0 votes
- 0 copies
- 2 views
- Added December 4, 2026
Works with
Security analysis
100/100Pro scans all 2 files and shows the line behind each finding
npx -y skills add turkishtechnology/takeoff-v2 --skill takeoff-anchor --agent claude-codeAre you the author of Takeoff Anchor?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/turkishtechnology-takeoff-anchor)---
name: takeoff-anchor
description:
Use the Anchor component from @takeoff-ui/react-spar to build an in-page table
of contents that follows the scroll position (scroll spy), highlights the
section in view, scrolls smoothly to a section on press and supports nested
links. Use whenever building, importing, styling, or fixing an "On this page"
list, a docs or settings page table of contents, section navigation, or a
scroll-spy menu in a Takeoff / Spar React app.
---
# Anchor — @takeoff-ui/react-spar
Use `Anchor` for navigation between sections of the same page. It renders a
`<nav>` landmark with a list of links; the Spar `Anchor` primitive watches the
scroll container and marks the link of the section in view with
`aria-current="location"`. A link press scrolls smoothly to its section, moves
focus there and writes the hash.
**When to use:** Long docs, settings, policy or detail pages with a side table
of contents. Not this — use `takeoff-tabs` to switch panels in place,
`takeoff-sidebar` for app-level navigation between pages, and
`takeoff-breadcrumb` for the location in a hierarchy.
## Quick start
```tsx
import { Anchor } from '@takeoff-ui/react-spar';
<Anchor>
<Anchor.Link href="#overview">Overview</Anchor.Link>
<Anchor.Link href="#baggage">Baggage</Anchor.Link>
<Anchor.Group>
<Anchor.Link href="#cabin">Cabin baggage</Anchor.Link>
<Anchor.Link href="#checked">Checked baggage</Anchor.Link>
</Anchor.Group>
<Anchor.Link href="#seats">Seat selection</Anchor.Link>
</Anchor>;
```
Every `href` is a fragment pointing at an element `id` on the page.
## Anatomy
```tsx
<Anchor>
<Anchor.Link />
<Anchor.Group>
<Anchor.Link />
</Anchor.Group>
</Anchor>
```
The root renders `<nav>` + a `<ul>` (`list` slot, draws the track). Each
`Anchor.Link` renders `<li>` (`item` slot) + `<a>`; `Anchor.Group` renders
`<li>` + a nested `<ul>`. Place a group right after the link of its parent
section.
## Common patterns
```tsx
// Sections scroll inside an element, under a 64px sticky header.
const ref = useRef<HTMLDivElement>(null);
const getContainer = useCallback(() => ref.current, []);
<Anchor getContainer={getContainer} offset={64}>…</Anchor>
// Table of contents on the right of the content.
<Anchor placement="end" size="small">…</Anchor>
// Track the current section in app state.
const [section, setSection] = useState('');
<Anchor value={section} onValueChange={setSection}>…</Anchor>
// Keep the URL alone (e.g. a hash router).
<Anchor hashMode="none">…</Anchor>
// A count beside the label (aria-hidden: say it in the label if it matters).
<Anchor.Link href="#inbox" endContent="12">Inbox</Anchor.Link>
```
## Key props
| Prop | Part | Type | Default | Notes |
| ----------------------------- | ------------- | ------------------------------- | ---------------- | ------------------------------------------------------------------------------------- |
| `size` | `Anchor` | `'small' \| 'base' \| 'large'` | `'base'` | Padding and type scale; group links are one step smaller. |
| `placement` | `Anchor` | `'start' \| 'end'` | `'start'` | Side of the track and the current-section indicator. |
| `value` / `defaultValue` | `Anchor` | `string` | `''` | `href` of the current section; `''` = none. |
| `onValueChange` | `Anchor` | `(value: string) => void` | — | Fires once per change, from scrolling or a link press. |
| `offset` | `Anchor` | `number` | `0` | Activation line in px from the container top; also where a press scrolls to. |
| `bounds` | `Anchor` | `number` | `5` | Tolerance below the line. |
| `getContainer` | `Anchor` | `() => HTMLElement \| Window` | `() => window` | Scroll container; keep it stable (`useCallback`). |
| `scrollBehavior` | `Anchor` | `'smooth' \| 'auto'` | `'smooth'` | `smooth` drops to `auto` under reduced motion. |
| `hashMode` | `Anchor` | `'push' \| 'replace' \| 'none'` | `'push'` | How a press writes the hash. |
| `aria-label` | `Anchor` | `string` | `'On this page'` | Landmark name; empty falls back to the default. |
| `href` | `Anchor.Link` | `string` | — | `#id` of the section. Non-fragment hrefs navigate normally. |
| `disabled` | `Anchor.Link` | `boolean` | `false` | No `href`, skipped by Tab, `aria-disabled`. |
| `startContent` / `endContent` | `Anchor.Link` | `ReactNode` | — | Icon or count; `aria-hidden`. |
| `classNames` / `slotProps` | every part | per-slot map | — | Slots: root `root` `list`; link `root` `item` `content` `label`; group `root` `item`. |
## Behavior notes
- The pressed section stays current until the scroll settles; the spy resumes on
the next scroll.
- At the end of the container, the last section on screen becomes current even
if it cannot reach the activation line.
- A consumer `onClick` runs first; `event.preventDefault()` cancels the scroll.
Modified clicks (new tab / window) keep the browser's behavior.
- Controlled `value` decides the highlight; the spy keeps calling
`onValueChange`.
## Accessibility
- `<nav>` landmark named "On this page" by default; links in a list, groups as
nested lists.
- The current link has `aria-current="location"`.
- A press focuses the section (adding `tabindex="-1"` when needed) so the next
Tab continues from it.
Read `references/full-docs.md` for all props, examples, slots, data attributes,
and type definitions.
## Source
- Docs: `apps/docs/docs/components/anchor.mdx`
- Component: `packages/react-spar/src/components/anchor/`
- Spar primitive: `packages/spar/src/components/Anchor/`
Files in this skill
- SKILL.md
- references/full-docs.md
Attribution
Related skills
View all in devops →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.