Components
Link
Link is clickable text or graphics that take the user to other pages or documents.
React
Press Enter to start editing
const PreviewEn = () => { const rand = useId(); return ( <Link href={'/en/patterns/external-links/' + rand}>Labelling links</Link> ); }; render(<PreviewEn />)
- children
- Description
The content to display inside the link.
- Type
any
- asChild
- Description
Change the default rendered element for the one passed as a child, merging their props and behavior.
- Type
boolean- Default
false
| Name | Type | Default | Description |
|---|---|---|---|
| children | any | - | The content to display inside the link. |
| asChild | boolean | false | Change the default rendered element for the one passed as a child, merging their props and behavior. |
Usage
The component is an <a> element, and on MDN Web Docs you can read more about the anchor HTML tag (mozilla.org).
Examples
In text
React
Press Enter to start editing
const InTextEn = () => { const rand = useId(); return ( <Paragraph> We use components from{' '} <Link href={'https://designsystemet.no?q=' + rand}> designsystemet.no </Link> . </Paragraph> ); }; render(<InTextEn />)
With icon
React
Press Enter to start editing
const WithIconEn = () => { return ( <Link href='https://designsystemet.no/slack'> <Chat2Icon aria-hidden fontSize={24} /> <span>Talk to us on Slack</span> </Link> ); }; render(<WithIconEn />)
Neutral color
React
Press Enter to start editing
const NeutralEn = () => { const rand = useId(); return ( <Link href={'/en/fundamentals/privacy-policy' + rand} data-color='neutral'> Privacy Policy </Link> ); }; render(<NeutralEn />)
HTML
Use the class name ds-link on an <a> element to apply the style of the Link component.
CSS variables and data attributes
| Name | Value |
|---|---|
| --dsc-link-background--active | var(--ds-color-surface-tinted) |
| --dsc-link-color--active | var(--ds-color-text-default) |
| --dsc-link-color--hover | var(--ds-color-text-default) |
| --dsc-link-color | var(--ds-color-text-subtle) |
| --dsc-link-color--visited | var(--ds-link-color-visited) |
| --dsc-link-text-decoration-thickness--hover | 0.125em |
| --dsc-link-text-decoration-thickness | 0.0625em |
| --dsc-link-border-radius | var(--ds-border-radius-md) |
No relevant data attributes found.
Edit this page on github.com (opens in a new tab)