Skip to content
Back to skills

Takeoff Anchor

ASecurity

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`...

  • 3 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added December 4, 2026
devopsreactnodeaws

Works with

  • cli

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned December 4, 2026

npx -y skills add turkishtechnology/takeoff-v2 --skill takeoff-anchor --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Takeoff Anchor?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Takeoff Anchor
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/turkishtechnology-takeoff-anchor/badge)](https://www.skillsdirectory.com/skills/turkishtechnology-takeoff-anchor)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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.md6.6 KB
  • references/full-docs.md18.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in devops →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.