Skip to content
Alea0.1

Navigation

Anchor

On-page navigation that follows the section you are reading.

Ant Design: Anchor

import { Anchor } from '@alea/ui';

Examples

Anchor

The links follow the section in view. Scroll the page to see it move.

Props

Anchor props

On-page navigation that follows the section you are reading (Ant's Anchor).

PropTypeDefaultDescription
itemsrequired{ id: string; label: ReactNode; level?: 2 | 3 | undefined; }[]-The sections: id of the heading or section, and the link text. Nest with level 2 or 3.
classNamestring-Extra class names for the root element.
offsetnumber80Space taken by a sticky header, so the active section is right. Default 80.
titleReactNode'On this page'Title above the links. Default "On this page".

Accessibility

  • A navigation landmark; the section in view is marked aria-current="location".

Keyboard

KeyDoes
TabMoves between section links
EnterScrolls to the section

Do and don't

Do

  • Use it on long pages with three or more sections.
  • Keep the labels the same as the headings.

Don't

  • Don't use it for site navigation: use NavigationMenu or the sidebar.
  • Don't link to sections that are hidden.
Tested with axe, keyboard and screen reader roles