LinkButton

A LinkButton looks like a button but behaves like a link.

Anatomy

Composed Components

A LinkButton uses the following components.

Usage

Variants

A link button can use different variants.

Primary - For the principal call to action on the page. Primary buttons should only appear once per screen — not including the application header, modal or side panel.

Secondary - For secondary actions on each page. Secondary buttons can be used in conjunction with a primary link button or on its own. Paired with a Primary link button, the secondary link button usually performs the negative action of the set, such as “Cancel.”

Upsell - For upsell actions that relate to upgrading an account or a plan. Use the upsell link button to distinguish it from an existing primary link button. In some cases, a primary link button can be used instead when the general context of the page is about upselling.

Danger - For actions that could have destructive effects on the user’s data.

Ghost-[primary|secondary|danger] - For less prominent, and sometimes independent, actions. Ghost buttons can be used in isolation or paired with a primary link button when there are multiple calls to action. Ghost buttons can also be used for subtasks on a page where a primary link button for the main and final action is present.

Sizes

A link button can vary in size.

Disabled

A link button can be disabled.

External

Add rel="noopener noreferrer" and target="_blank" attributes to render and external link button.

No Href

When a link button link does not have an href prop, it is rendered as a <span role="link"> instead of an <a>. Events will need to be handled in JavaScript with the onPress prop.

Note: this will not behave like a native link. Browser features like context menus and open in a new tab will not apply.

Fluid

A link button can be expanded to full width to fill its parent container.

Icon Only

A link button can contain only an icon.

Icon

A link button can contain icons.

End Icon

Nonstandard end icons can be provided to handle special cases. However, think twice before adding end icons, start icons should be your go-to.

Props

variant?

The visual style of the button.

Defaults to primary.
size?

A button can vary in size.

Defaults to md.
isFluid?

Whether or not the button takes up the width of its container.

style?

The inline style for the element. A function may be provided to compute the style based on component state.

autoFocus?

Whether the element should receive focus on render.

href?

A URL to link to. See MDN.

hrefLang?

Hints at the human language of the linked URL. SeeMDN.

target?

The target window for the link. See MDN.

rel?

The relationship between the linked resource and the current page. See MDN.

download?

Causes the browser to download the linked URL. A string may be provided to suggest a file name. See MDN.

ping?

A space-separated list of URLs to ping when the link is followed. See MDN.

referrerPolicy?

How much of the referrer to send when following the link. See MDN.

routerOptions?

Options for the configured client side router.

children?

The children of the component. A function may be provided to alter the children based on component state.

className?

The CSS className for the element. A function may be provided to compute the class based on component state.

Migration Notes

Coming from Orbiter, you should be aware of the following changes:

  • onClick has been renamed to onPress to be closer to the React Aria API.
  • Counter is no longer allowed as a specialized slot.
  • ButtonAsLink is renamed to LinkButton.