Skip to content


The Anchor, also knows as Link is used to navigate from one page to the next HTML page.

import { Link, Anchor } from '@dnb/eufemia'
render(<Anchor href="/uilib/components/anchor">Accessible text</Anchor>)

Combine a Link with an Anchor

You can combine a meta framework link, with the Anchor. This way, all the framework provided features will still work, as well as the behavior of the Eufemia Anchor.

import Anchor from '@dnb/eufemia/components/Anchor'
import { Link } from 'gatsby'
<Anchor element={Link} to="/path">

Anchor hash

Some browsers like Chrome (behind a flag) does still not support animated anchor hash clicks when CSS scroll-behavior: smooth; is set. To make it work, you can provide the scrollToHashHandler helper function to the Anchor:

import Anchor, {
} from '@dnb/eufemia/components/Anchor'
<Anchor href="/path#hash-id" onClick={scrollToHashHandler}>
<div id="hash-id">element to scroll to</div>

Blank target

NB: If you only use a vanilla HTML anchor element including target="_blank" then you have to ensure you add a title attribute that includes Opens a new Window or as a part of the text:

title="Opens a new Window"
text (opens in new window)


Basic usage

The basic use of <Anchor> is identical to the <a> tag.

This is a regular paragraph with a link to a website in the middle of some text.

Code Editor
  This is a regular paragraph with a{' '}
  <Anchor href="">link to a website</Anchor> in the middle
  of some text.

With icon

Icons can be added with the icon and iconPosition props. Normally by sending in the name if an icon, but it is also possible to send in html/react code (normally for custom svg).

A text paragraph with an anchor with icon in it.

Additional Anchor helper classes

To force a specific state of style, use the following classes to do so:

Anchor modifiers

Anchor with target="_blank"

If the link opens a new window it will automatically get an icon to indicate this.

Unless the href contains :mailto, :tel or :sms.

Anchor in headings

Anchor in Section

Code Editor
<Section spacing>
  <Anchor className="dnb-anchor--no-underline" href="">
    Anchor in Section without underline