ButtonLink is mainly used as a navigational element to direct users to a new page or location.

Figma:

Responsive:

Adaptive:

A11y:

Props

Component props
Name
Type
Default
href
Required
string
-

Specifies a link URL.

text
Required
string
-

Text to render inside the ButtonLink to convey the function and purpose of the ButtonLink.

accessibilityLabel
string
-

Label to provide more context around ButtonLink’s function or purpose. See the Accessibility guidelines to learn more.,

color
"gray"
| "red"
| "blue"
| "transparent"
| "semiTransparentWhite"
| "transparentWhiteText"
| "white"
"gray"

The background color of ButtonLink.

dataTestId
string
-

Available for testing purposes, if needed. Consider better queries before using this prop.

disabled
boolean
false

Indicates if ButtonLink is disabled. Disabled Buttons are inactive and cannot be interacted with.

fullWidth
boolean
false

Default Buttons are sized by the text within the ButtonLink whereas full-width Buttons expand to the full width of their container.

iconEnd
unknown
-

An icon displayed after the text to help clarify the usage of ButtonLink. See the icon variant to learn more.

onClick
({|
  event: SyntheticMouseEvent<HTMLAnchorElement> | SyntheticKeyboardEvent<HTMLAnchorElement>,
  dangerouslyDisableOnNavigation: () => void,
|}) => void
-

Callback invoked when the user clicks (press and release) on ButtonLink with the mouse or keyboard.
See GlobalEventsHandlerProvider to learn more about link navigation.

rel
"none" | "nofollow"
"none"

Provides hints for SEO. See the MDN Web Docs to learn more.

size
"sm" | "md" | "lg"
"md"

sm: 32px, md: 40px, lg: 48px

tabIndex
-1 | 0
0

Use "-1" to remove ButtonLink from keyboard navigation. See the Accessibility guidelines to learn more.

target
null | "self" | "blank"
"null"

Indicates the browsing context where an href will be opened:

  • 'null' opens the anchor in the same window.
  • 'blank' opens the anchor in a new window.
  • 'self' opens an anchor in the same frame.

Localization

Be sure to localize text and accessibilityLabel. Note that localization can lengthen text by 20 to 30 percent. Avoid truncating ButtonLink text whenever possible. Refer to the ButtonLink usage guidelines for more information.

Usage guidelines

When to use
  • Communicating a navigation that will occur.
  • Triggering or enabling a navigation, such as visiting another URL.
  • Progressing or regressing a user through a step in a flow in separate URLs.
When not to use
  • Inlined in text. Instead, use Link.
  • Limited space available. Consider using an IconButtonLink instead.

Best practices

Do

Place primary ButtonLinks to the right or top of other ButtonLink styles.

Don't

Place more than one primary ButtonLink per container/area.

Do

Show the full text on ButtonLinks. ButtonLinks should be stacked when they cannot be displayed side by side.

Don't

Truncate the ButtonLink text. In rare instances where ButtonLinks must remain on one line, truncate the text on the secondary ButtonLink before truncating on the primary ButtonLink.

Do

Use an IconButton + Tooltip next to the disabled ButtonLink if you need to explain why it is disabled.

Don't

Use a Tooltip on disabled ButtonLink, as it is not accessible for keyboard and screen reader users.

Accessibility

Variants

External handlers

ButtonLink consumes external handlers from GlobalEventsHandlerProvider.

Handlers:

See GlobalEventsHandlerProvider for more information.

Icons

iconEnd adds an icon after the ButtonLink text. Icons should only be used to visually reinforce a specific function or interaction of the ButtonLink. Menus and external links are a common use case. The icon visit is recommended for use with ButtonLink. Note that iconEnd on ButtonLink is not accessible to screen readers.

import { ButtonLink, Flex } from 'gestalt';

export default function Example() {
  return (
    <Flex
      alignItems="center"
      height="100%"
      justifyContent="center"
      width="100%"
    >
      <ButtonLink
        accessibilityLabel=""
        iconEnd="visit"
        size="lg"
        text="Visit Pinterest"
        href="https://www.pinterest.com/"
      />
    </Flex>
  );
}

States

  1. Default
    The typical state of a ButtonLink that represents it can be interacted with and is not in a selected state.
  2. Disabled
    Used to block user interaction such as hover, focus and click. Disabled Buttons are completely unreachable by a keyboard and screenreader, so do not attach Tooltips to disabled Buttons.
import { ButtonLink, Flex } from 'gestalt';

export default function Example() {
  return (
    <Flex
      alignItems="center"
      height="100%"
      justifyContent="center"
      width="100%"
    >
      <ButtonLink
        accessibilityLabel="Visit Pinterest"
        color="red"
        text="Visit Pinterest"
        size="lg"
        href="https://www.pinterest.com/"
      />
    </Flex>
  );
}

import { ButtonLink, Flex } from 'gestalt';

export default function Example() {
  return (
    <Flex
      alignItems="center"
      height="100%"
      justifyContent="center"
      width="100%"
    >
      <ButtonLink
        accessibilityLabel="Go back"
        disabled
        text="Go back"
        size="lg"
        href="https://www.pinterest.com/"
      />
    </Flex>
  );
}

rel and target

These optional props control the behavior of ButtonLink. External links commonly use target="_blank" to open the link in a new tab or window, and rel="nofollow" to provide hints for SEO.

import { ButtonLink, Flex } from 'gestalt';

export default function Example() {
  return (
    <Flex
      alignItems="center"
      height="100%"
      justifyContent="center"
      width="100%"
    >
      <ButtonLink
        accessibilityLabel="Visit Pinterest"
        iconEnd="visit"
        size="lg"
        text="Visit Pinterest"
        rel="nofollow"
        target="blank"
        href="#"
      />
    </Flex>
  );
}

Component quality checklist

Component quality checklist
Quality item
Status
Status description
Figma Library
Component is not currently available in Figma.
Responsive Web
Ready
Component responds to changing viewport sizes in web and mobile web.

Button
Use Button when an action is needed instead of a link.

ButtonGroup
When displaying multiple ButtonLinks in a layout, use ButtonGroup to ensure consistent spacing and wrapping behavior.

IconButton
Use IconButton when only an icon is needed instead of text.

TapArea
Use TapArea to make non-button elements interactive, like an Image. This ensures the element interaction is accessible and uses Gestalt styles.

Tabs
Tabs are intended for page-level navigation between multiple URLs.

GlobalEventsHandlerProvider
GlobalEventsHandlerProvider allows external link navigation control across all children components with link behavior.
See GlobalEventsHandlerProvider to learn more about link navigation.