Skip to content
THE COMPONENT LIBRARY
Skip to content

Component reference

Anchor

Permalinks associated with article headings.

Preview

Live preview

Changes apply to this preview only.

Width adapts to the available space

More examples

Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.

Heading levels

level accepts 1 to 6 and defaults to 2. The visual scale changes, the heading role stays semantic.

Open preview

Copy feedback

Activating the # link writes location.href#id to the clipboard and announces the result through a polite status. onCopy receives the exact URL.

Open preview

Custom destination and label

href replaces the default #id destination without changing the copied URL. copyLabel names the link for assistive technology.

Open preview

Usage

Use stable unique heading ids and meaningful destinations.

API reference

Generated from the public TypeScript declarations. Native HTML attributes are inherited where the component extends them; this reference includes Pimolu props and selected common native attributes.

PimoluAnchorProps

Type source
PimoluAnchorProps public API
NameTypeDefaultDescription
idRequiredstring—Id of the heading and of its hash target.
levelPimoluAnchorLevel | undefined2Heading level, 1 to 6. Defaults to 2.
childrenRequiredReactNode—Heading text.
copyLabelstring | undefined"Copy link to section"Accessible name of the self-link. Defaults to "Copy link to section".
hrefstring | undefined"#<id>"Destination of the self-link. Defaults to "#<id>".
onCopy((value: string) => void) | undefined—Called with the copied URL after a successful clipboard write.
classNamestring | undefined—Class applied to the wrapper that hosts the heading and the link.
onChangeChangeEventHandler<HTMLHeadingElement, Element> | undefined—Standard React/HTML attribute.
defaultValuestring | number | readonly string[] | undefined—Standard React/HTML attribute.
styleCSSProperties | undefined—Standard React/HTML attribute.
aria-labelstring | undefined—Defines a string value that labels the current element.
onClickMouseEventHandler<HTMLHeadingElement> | undefined—Standard React/HTML attribute.
idRequired

string

No default extracted.

Id of the heading and of its hash target.

level

PimoluAnchorLevel | undefined

Default: 2

Heading level, 1 to 6. Defaults to 2.

childrenRequired

ReactNode

No default extracted.

Heading text.

copyLabel

string | undefined

Default: "Copy link to section"

Accessible name of the self-link. Defaults to "Copy link to section".

href

string | undefined

Default: "#<id>"

Destination of the self-link. Defaults to "#<id>".

onCopy

((value: string) => void) | undefined

No default extracted.

Called with the copied URL after a successful clipboard write.

className

string | undefined

No default extracted.

Class applied to the wrapper that hosts the heading and the link.

onChange

ChangeEventHandler<HTMLHeadingElement, Element> | undefined

No default extracted.

Standard React/HTML attribute.

defaultValue

string | number | readonly string[] | undefined

No default extracted.

Standard React/HTML attribute.

style

CSSProperties | undefined

No default extracted.

Standard React/HTML attribute.

aria-label

string | undefined

No default extracted.

Defines a string value that labels the current element.

onClick

MouseEventHandler<HTMLHeadingElement> | undefined

No default extracted.

Standard React/HTML attribute.

Accessibility

  • Keep the permalink keyboard reachable and provide a clear accessible name for icon-only links.
Read the accessibility guide →