---
title: Link
---

import LibraryInfo from '@theme/LibraryInfo'
import { Feedback, TokensTable, PropsTable } from '../../src/components'
import { Link, Card } from '@telus-uds/components-web'
import { LinkBase as BaseDocs } from 'docs/@telus-uds/components-base'
import { Profile, Settings } from '@telus-uds/palette-allium/build/web/icons'
import AvailableOnBoth from '../../partials/_platform-considerations-both.mdx'

# Link

<LibraryInfo figmaLink="https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2F4zJn2Qn6uXOqPP1GVDipy6%2F%25F0%259F%258D%2580-Allium-Components%3Fnode-id%3D405%253A201" />

```jsx live
<Link href="https://www.telus.com">Go to telus.com</Link>
```

## Introduction

A Link is a navigational element to take a user to a page.

[Follow the appropriate instructions](importing-components) to add this component in to your app.

## Guidance

Links should usually be used as standalone block-level elements. Keep choices
simple and avoid listing many links outside of clearly labelled menus.

### Alternatives

**Do not** use Link for:

- Actions that occur immediately on press: consider [Button](button)
- Choices presented as calls to action: consider [ButtonLink](button-link)
- Actions that occur within the current page or screen: consider [TextButton](text-button)
- One navigation action that represents the user's logical next step: consider [ChevronLink](chevron-link)

### Inline links

Links may be nested within text, but consider that it is usually clearer to present
navigation options after a user has completed a section or action, rather than as
a mid-paragraph interruption.

Inline links should be used very sparingly; for example, for asides of interest only to a minority of readers.

```jsx live
<StackView space={3}>
  <Typography variant={{ size: 'small' }}>
    We never compromise on data security. All your personal data is stored safely in our secure
    vault. These extensive precautions we take to keep your data safe are detailed in the{' '}
    <Link href="https://telus.com" variant={{ size: 'small' }}>
      Data Security
    </Link>{' '}
    section of our privacy policy.
  </Typography>
  <ButtonLink variant={{ size: 'small' }} href="https://telus.com">
    Sign up
  </ButtonLink>
  <Link variant={{ size: 'small' }} href="https://telus.com">
    View full privacy policy
  </Link>
</StackView>
```

Note that Links **do not** automatically inherit text styles from surrounding
text. Their styles are set specifically to the on-brand variants listed below.

### Accessibility

Insert [A11yText](a11y-text) any time an interactive element's label lacks context
that a sighted user would see in the content around it. Many users of assistive technology explore a page
by cycling through the interactive elements first.

```jsx
import { DownloadPdf, Print } from '@telus-uds/palette-allium/build/web/icons'
```

```jsx live
<StackView space={3}>
  <Typography>Your contract is valid until April 9 2024.</Typography>
  <Link icon={Icons.DownloadPdf} href="https://telus.com">
    Download PDF
    <A11yText text="of your contract" />
  </Link>
  <Link icon={Icons.Print} href="https://telus.com">
    Print
    <A11yText text="your contract" />
  </Link>
</StackView>
```

### Platform considerations

<AvailableOnBoth />

On web, Link will render as an `<a>` anchor link if a `href` is provided, allowing for
common link actions such as open in new tab.

On native apps, links to web addresses will be opened according to the user's device's link handling
behaviour: usually opening the user's default browser (or choice of browsers) with a back action to return
to the app.

## Props

<PropsTable base={BaseDocs} />

## Tokens

<TokensTable base={BaseDocs} component="Link" />

### Use of `dataSet`

Use `dataSet` prop to pass custom data attributes. Here's an example:

```jsx live
<Link
  href="https://www.telus.com"
  dataSet={{ 'field-id': 'test field id', 'entry-id': 'test entry id' }}
>
  Go to telus.com
</Link>
```

## Variants

### Size

Link's `size` variants correspond to equivalent [Typography](typography) body text size variants, with fine adjustments applied where necessary
for accessibility and usability. Choose sizes that complement surrounding text content.

#### size: 'large'

```jsx live
<Link href="https://telus.com" variant={{ size: 'large' }}>
  Large link
</Link>
```

#### default (medium) size

```jsx live
<Link href="https://telus.com">Default link</Link>
```

#### size: 'small'

```jsx live
<Link href="https://telus.com" variant={{ size: 'small' }}>
  Small link
</Link>
```

#### size: 'micro'

```jsx live
<Link href="https://telus.com" variant={{ size: 'micro' }}>
  Micro link
</Link>
```

### Style

:::info

Introducing the new `style` variants. These new variants enable brands to design more comprehensively
according to their visual language, support the ability to easily swap between brands, and provide
more intuitive and intentional use.

:::

#### Default

```jsx live
<StackView space={1}>
  <Link href="https://telus.com">Default variant</Link>
  <Link variant={{ style: 'inline' }} href="https://telus.com">
    Inline variant
  </Link>
  <Link variant={{ style: 'subtle' }} href="https://telus.com">
    Subtle variant
  </Link>
  <Link variant={{ style: 'feature' }} href="https://telus.com">
    Feature variant
  </Link>
  <Link variant={{ style: 'danger' }} href="https://telus.com">
    Danger variant
  </Link>
  <Card variant={{ style: 'darkest' }}>
    <Link variant={{ style: 'inverse' }} href="https://telus.com">
      Inverse variant
    </Link>
  </Card>
</StackView>
```

#### Quiet

```jsx live
<StackView space={1}>
  <Link variant={{ quiet: true }} href="https://telus.com">
    Default variant
  </Link>
  <Link variant={{ style: 'inline', quiet: true }} href="https://telus.com">
    Inline variant
  </Link>
  <Link variant={{ style: 'subtle', quiet: true }} href="https://telus.com">
    Subtle variant
  </Link>
  <Link variant={{ style: 'feature', quiet: true }} href="https://telus.com">
    Feature variant
  </Link>
  <Link variant={{ style: 'danger', quiet: true }} href="https://telus.com">
    Danger variant
  </Link>
  <Card variant={{ style: 'darkest' }}>
    <Link variant={{ style: 'inverse', quiet: true }} href="https://telus.com">
      Inverse variant
    </Link>
  </Card>
</StackView>
```

### Alternative

:::caution

The `alternative` variant is deprecated and will be removed in preference of the `style` variant.

:::

Set a link in the "alternative" style using `variant={{ alternative: true }}` in cases where a less eye-catching grey is more appropriate.

As this is less visually distinct, be careful to only use this variant where it is obvious from context that this is a link.

```jsx live
<Link href="https://telus.com" variant={{ alternative: true }}>
  Alternative link
</Link>
```

### Inverse

:::caution

The `inverse` variant is deprecated and will be removed in preference of the `style` variant.

:::

Use inverse links on darker backgrounds.

```jsx live
<Box space={3} variant={{ background: 'darkest' }}>
  <Link href="https://telus.com" variant={{ inverse: true }}>
    Inverse link
  </Link>
</Box>
```

### Quiet

- Quiet links minimize visual attention by removing the underline.
- Quiet links are less accessible than default links. Please consider adding other cues to indicate they're interactive with a strong call to action, icons, or contextually as a group.

```jsx live
<StackView space={3}>
  <Link href="https://telus.com" variant={{ quiet: true }}>
    Quiet link
  </Link>
</StackView>
```

### Icons

Icons may be imported and passed to the `icon` prop. Note that only icons from the
section tagged ["Links"](icons-allium#links) should be used in a Link.

### iconPosition

`iconPosition` prop can be used to align the icon to the `right`, `left` or `inline`.

#### `left`

The icon is aligned to the left of the text using `iconPosition` prop.

Note: `left` is the default alignment for Link.

```jsx
import { LinkExternal } from '@telus-uds/palette-allium/build/web/icons'
```

```jsx live
<Link href="https://telus.com" icon={Icons.LinkExternal} iconPosition="left">
  Open external page
</Link>
```

#### `right`

The icon is aligned to the right of the text using `iconPosition` prop.

```jsx
import { LinkExternal } from '@telus-uds/palette-allium/build/web/icons'
```

```jsx live
<Link href="https://telus.com" icon={Icons.LinkExternal} iconPosition="right">
  Open external page
</Link>
```

#### `inline`

The icon is aligned inline of the text using `iconPosition` prop.

```jsx
import { LinkExternal } from '@telus-uds/palette-allium/build/web/icons'
```

```jsx live
<Link href="https://telus.com" icon={Icons.LinkExternal} iconPosition="inline">
  This is an example of an icon aligned inline with the text, with the iconPosition prop the icon
  can be aligned to the right, can be aligned to the left or can be inline with the text as in this
  example.
</Link>
```

## Feedback

<Feedback component="Link" />
