Workday Canvas

Hyperlink

Hyperlinks take users somewhere else in the app, or a different site.

v14.2.34
Install
yarn add @workday/canvas-kit-react

Anatomy

The basic elements of a hyperlink

  1. Text: Describes where the link goes.
  2. Underline (conditional): Appears when the link is inline with body text.
  3. External link icon (conditional): extLink system icon that appears when the link navigates to a different site entirely.

Usage Guidance

Hyperlinks (also known as links) are interactive elements that navigate somewhere else, such as another page, or a different site entirely. Links may also act as anchor tags that navigate to users to sections on the same page, like in a table of contents.

Hyperlinks may appear inline with body text or as a standalone link. When a hyperlink is used inline with body text, an underline is used to differentiate it from surrounding text to avoid relying on color alone to communicate interactivity.

When to Use

  • Use a Hyperlink to navigate to a different page or view within the app
  • Use an External Hyperlink to navigate to a different site entirely. External Hyperlinks are indicated by an extLink system icon placed at the end.
  • Hyperlinks may be used as anchor tags to navigate to different sections on a page.
  • Use a standalone Hyperlink when you need to place a Hyperlink outside of a paragraph or body text. This will remove the underline.

When to Use Something Else

  • Use a Button for any action that changes state or triggers a process or workflow.
  • Use Tabs to organize and switch between related sections on the same page. Tabs hide content to preserve screen real estate.
  • Use Breadcrumbs to expose and navigate a hierarchy of pages.

Examples

Hyperlinks should be used when you want to navigate away from the current page or to an anchor on the current page. By default, Hyperlinks have an underline for accessibility.

Hyperlink
import {Hyperlink} from '@workday/canvas-kit-react/button';

export default () => <Hyperlink href="#hyperlink">Hyperlink</Hyperlink>;

Inverse

Hyperlinks also have an inverse variant. Use this variant when you need to place a Hyperlink on a dark or colorful background.

import React from 'react';

import {Hyperlink} from '@workday/canvas-kit-react/button';
import {Box} from '@workday/canvas-kit-react/layout';
import {createStyles} from '@workday/canvas-kit-styling';
import {system} from '@workday/canvas-tokens-web';

const parentContainerStyles = createStyles({
  backgroundColor: system.color.bg.primary.default,
  padding: system.space.x4,
  display: 'inline-flex',
  gap: system.space.x4,
});

export default () => (
  <Box cs={parentContainerStyles}>
    <Hyperlink href="#hyperlink" variant="inverse">
      Hyperlink
    </Hyperlink>
    <Hyperlink href="#hyperlink" variant="standaloneInverse">
      Hyperlink
    </Hyperlink>
  </Box>
);

Standalone

Hyperlinks also have a standalone variant. Use this variant when you need to place a Hyperlink outside of a paragraph or body text. This will remove the underline.

This variant can also be used with the ExternalHyperlink component.

import {Hyperlink, ExternalHyperlink} from '@workday/canvas-kit-react/button';
import {createStyles} from '@workday/canvas-kit-styling';
import {system} from '@workday/canvas-tokens-web';

const containerStyles = createStyles({
  display: 'inline-flex',
  gap: system.space.x4,
});

export default () => (
  <div className={containerStyles}>
    <Hyperlink variant="standalone" href="#standalone-hyperlink">
      Standalone Hyperlink
    </Hyperlink>
    <ExternalHyperlink
      variant="standalone"
      href="#standalone-external-hyperlink"
      iconLabel="Opens new window"
    >
      Standalone External Hyperlink
    </ExternalHyperlink>
  </div>
);

In Body Text

In most cases use HyperLink and ExternalHyperlink in body text of a sentence where you need to link to another page or part of the document. By default they will wrap to a new line.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmodtempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit involuptate velit esse cillum dolore eu fugiatnulla pariatur.

import {Hyperlink} from '@workday/canvas-kit-react/button';

export default () => (
  <p>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
    <Hyperlink href="#hyperlink">tempor incididunt</Hyperlink> ut labore et dolore magna aliqua. Ut
    enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in
    <Hyperlink href="#hyperlink">voluptate velit esse cillum dolore eu fugiat</Hyperlink>
    nulla pariatur.
  </p>
);

Accessibility Note: Underlining links is not required in most cases. However, the example above is one such exception. When hyperlinked text appears inline with static text, a text decoration is required to avoid failing WCAG v2.2 success criterion 1.4.1 Use of Color.

Failure of Success Criterion 1.4.1 due to creating links that are not visually evident without color vision

Accessibility

Our link components render semantic HTML <a> elements to the browser DOM. This means that ARIA roles won’t be necessary in most cases. The href prop is required for accessibility. Activation links with the Enter key is standard expected behavior, while Space is only expected for buttons.

  • Use Hyperlinks when: Navigating to different pages or sections, or changing the browser’s location
  • Use Buttons when: Performing actions like submitting forms, opening modals, or triggering functions without navigation
  • Why This Matters: Screen reader users expect different behaviors from links vs buttons. Users navigate between links using different keyboard shortcuts than buttons. Browser behaviors like “Open in new tab” only work with proper links.

Common Mistakes to Avoid

  • Using buttons styled as links for navigation (breaks right-click context menus)
  • Using links for actions like “Delete” or “Save” (confuses user expectations)
  • Missing href attributes on navigation elements (breaks keyboard accessibility)
  • Using href="#" with onClick handlers instead of proper buttons

Component API

Props extend from a. Changing the as prop will change the element interface.

NameTypeDescriptionDefault
variant 'inverse' 'standalone' 'standaloneInverse'

sets modifier styles for Hyperlink

  • inverse: sets the color to white and updates hover, focus, and active pseudo-classes
  • standalone: removes the underline of the Hyperlink. This is useful when a hyperlink is used outside the context of a paragraph or body text.
  • standaloneInverse: removes the underline of the Hyperlink and sets the color to white. This is useful when a hyperlink is used outside the context of a paragraph or body text on a dark background.
hrefstring

attribute for the hyperlink URL

childrenReactNode
cs

The cs prop takes in a single value or an array of values. You can pass the CSS class name returned by , or the result of and . If you're extending a component already using cs, you can merge that prop in as well. Any style that is passed to the cs prop will override style props. If you wish to have styles that are overridden by the css prop, or styles added via the styled API, use wherever elemProps is used. If your component needs to also handle style props, use {@link mergeStyles } instead.

import {handleCsProp} from '@workday/canvas-kit-styling';
import {mergeStyles} from '@workday/canvas-kit-react/layout';

// ...

// `handleCsProp` handles compat mode with Emotion's runtime APIs. `mergeStyles` has the same
// function signature, but adds support for style props.

return (
 <Element
   {...handleCsProp(elemProps, [
     myStyles,
     myModifiers({ size: 'medium' }),
     myVars({ backgroundColor: 'red' })
   ])}
 >
   {children}
 </Element>
)
asReact.ElementType

Optional override of the default element used by the component. Any valid tag or Component. If you provided a Component, this component should forward the ref using React.forwardRefand spread extra props to a root element.

Note: Not all elements make sense and some elements may cause accessibility issues. Change this value with care.

a
refReact.Ref<R = a>

Optional ref. If the component represents an element, this ref will be a reference to the real DOM element of the component. If as is set to an element, it will be that element. If as is a component, the reference will be to that component (or element if the component uses React.forwardRef).

If your link should open in a new tab or window use the ExternalHyperlink component. It will let users know about the behavior by adding an icon, extLinkIcon.

Accessibility Note: Providing a label to the icon via the iconLabel prop is required for accessibility because the icon adds meaning to the link text. We recommend keeping the alt text as concise as possible, such as “Opens new window”. This override will be needed for translations.

External Hyperlink
import {ExternalHyperlink} from '@workday/canvas-kit-react/button';

export default () => (
  <ExternalHyperlink href="https://workday.com" iconLabel="Opens new window">
    External Hyperlink
  </ExternalHyperlink>
);

ExternalHyperlinks also have an inverse variant. Use this variant when you need to place the link on a dark or colorful background.

import React from 'react';

import {ExternalHyperlink} from '@workday/canvas-kit-react/button';
import {Box} from '@workday/canvas-kit-react/layout';
import {createStyles} from '@workday/canvas-kit-styling';
import {system} from '@workday/canvas-tokens-web';

const parentContainerStyles = createStyles({
  backgroundColor: system.color.bg.primary.default,
  padding: system.space.x4,
  display: 'inline-flex',
  gap: system.space.x4,
});

export default () => (
  <Box cs={parentContainerStyles}>
    <ExternalHyperlink
      href="https://workday.com"
      variant="inverse"
      iconLabel="Opens link in new window"
    >
      Hyperlink
    </ExternalHyperlink>
    <ExternalHyperlink
      href="https://workday.com"
      variant="standaloneInverse"
      iconLabel="Opens new window"
    >
      Hyperlink
    </ExternalHyperlink>
  </Box>
);

ExternalHyperlinks will also flip the icon for right-to-left (RTL) languages.

import {ExternalHyperlink} from '@workday/canvas-kit-react/button';
import {CanvasProvider, ContentDirection} from '@workday/canvas-kit-react/common';

export default () => (
  <CanvasProvider theme={{canvas: {direction: ContentDirection.RTL}}}>
    <ExternalHyperlink href="https://workday.com" iconLabel="Opens link in new window">
      השועל החום המהיר קופץ מעל הכלב העצל
    </ExternalHyperlink>
  </CanvasProvider>
);

Component API

Props extend from a. Changing the as prop will change the element interface.

NameTypeDescriptionDefault
iconLabelstring

Informs a screen reader user the link will open in a new window. It is read after the link text. This value will need to be translated.

variant 'inverse' 'standalone' 'standaloneInverse'

sets modifier styles for Hyperlink

  • inverse: sets the color to white and updates hover, focus, and active pseudo-classes
  • standalone: removes the underline of the Hyperlink. This is useful when a hyperlink is used outside the context of a paragraph or body text.
  • standaloneInverse: removes the underline of the Hyperlink and sets the color to white. This is useful when a hyperlink is used outside the context of a paragraph or body text on a dark background.
hrefstring

attribute for the hyperlink URL

childrenReactNode
cs

The cs prop takes in a single value or an array of values. You can pass the CSS class name returned by , or the result of and . If you're extending a component already using cs, you can merge that prop in as well. Any style that is passed to the cs prop will override style props. If you wish to have styles that are overridden by the css prop, or styles added via the styled API, use wherever elemProps is used. If your component needs to also handle style props, use {@link mergeStyles } instead.

import {handleCsProp} from '@workday/canvas-kit-styling';
import {mergeStyles} from '@workday/canvas-kit-react/layout';

// ...

// `handleCsProp` handles compat mode with Emotion's runtime APIs. `mergeStyles` has the same
// function signature, but adds support for style props.

return (
 <Element
   {...handleCsProp(elemProps, [
     myStyles,
     myModifiers({ size: 'medium' }),
     myVars({ backgroundColor: 'red' })
   ])}
 >
   {children}
 </Element>
)
asReact.ElementType

Optional override of the default element used by the component. Any valid tag or Component. If you provided a Component, this component should forward the ref using React.forwardRefand spread extra props to a root element.

Note: Not all elements make sense and some elements may cause accessibility issues. Change this value with care.

a
refReact.Ref<R = a>

Optional ref. If the component represents an element, this ref will be a reference to the real DOM element of the component. If as is set to an element, it will be that element. If as is a component, the reference will be to that component (or element if the component uses React.forwardRef).

Specifications

Content Guidelines

Coming soon!

Can't Find What You Need?

Check out our FAQ section which may help you find the information you're looking for. For further information, contact the #ask-canvas-design or #ask-canvas-kitchannels on Slack.

On this Page: