Anchor

An anchor is a primitive for building custom links.

Installation

Package installation information
Installyarn add @atlaskit/primitives
SourceBitbucket.org, (opens new window)
npm@atlaskit/primitives, (opens new window)
Bundleunpkg.com, (opens new window)

Props

Anchor also supports all valid HTMLAnchorElement props.

analyticsContext

Description

Additional information to be included in the context of Atlaskit analytics events that come from anchor.

Type{ [x: string]: any; }

children

Description

Elements to be rendered inside the Anchor.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal

componentName

Description

An optional component name used to identify this component in Atlaskit analytics events. This can be used if a parent component's name is preferred over the default 'Anchor'.

Typestring

data-testid

Description

data-testid is strictly controlled through the testId prop. This lets consumers know that this data attribute will not be applied.

Typenever

href

Required
Description

Standard links can be provided as a string, which should be mapped to the underlying router link component.

Alternatively, you can provide an object for advanced link configurations by supplying the expected object type to the generic.

@example

const MyRouterLink = forwardRef(
(
  {
    href,
    children,
    ...rest
  }: RouterLinkComponentProps<{
    href: string;
    replace: boolean;
  }>,
  ref: Ref<HTMLAnchorElement>,
) => { ...
Typestring | RouterLinkConfig

interactionName

Description
Typestring

newWindowLabel

Description

Override the default text to signify that a link opens in a new window. This is appended to the aria-label attribute when the target prop is set to _blank.

Typestring

onClick

Description

Handler called on click. The second argument provides an Atlaskit UI analytics event that can be fired to a listening channel. See the 'analytics-next' package documentation for more information.

Type(e: React.MouseEvent<HTMLAnchorElement, MouseEvent>, analyticsEvent: UIAnalyticsEvent) => void

ref

Description

Forwarded ref.

Type((instance: HTMLAnchorElement) => void) | React.RefObject<HTMLAnchorElement>

style

Description
No description.
TypeReact.CSSProperties

testId

Description

A unique string that appears as data attribute data-testid in the rendered code, serving as a hook for automated tests.

Typestring

xcss

Description

Apply a subset of permitted styles powered by Atlassian Design System design tokens.

Typefalse | (XCSSValue<"appearance" | "color" | "maxWidth" | "grid" | "borderColor" | "clipPath" | "filter" | "marker" | "mask" | "height" | "width" | "translate" | "content" | "border" | ... 487 more ... | "viewTimeline", DesignTokenStyles, ""> & ... 4 more ... & { ...; })
Was this page helpful?
We use this feedback to improve our documentation.
© 2026 AtlassianTrademark, (opens new window)Privacy, (opens new window)License