Anchor Design System

Button

Buttons allow users to perform actions and choose with a single tap.

Installation

Usage

Variants

Disabled

Pass the disabled prop to display disabled state of button.

Loading

Pass the loading prop to display a Spinner component inside the button.

Icon

You can add icons to the AnchorButton by passing the icon prop and adjust its position with icon-placement prop.

Accessibility

  • Button has role of button.
  • Keyboard event support for Space and Enter keys.
  • Mouse and touch event handling, and press state management.
  • Keyboard focus management and cross browser normalization.

We recommend to read this blog post about the complexities of building buttons that work well across devices and interaction methods.

API

Properties

PropertyAttributeDescriptionTypeDefault
disableddisabledSet whether or not the button should be disabled NB! This should be rarely be used as it's a potential accessibility issue. Disabled buttons are ignored by screen readers and keyboard navigation.booleanfalse
iconiconSet an icon to be displayed on the buttonstringundefined
iconPlacementicon-placementSet the position of the icon on a button with an icon"left" | "none" | "right"'none'
loadingloadingSet the Button state to loading to display a spinner iconbooleanfalse
onDarkon-darkSet to true if the Button is displayed on dark backgroundbooleanfalse
texttextSet a text to be displayed in the content slot of the buttonstringundefined
typetypeSet the type of button"button" | "reset" | "submit"'button'
uuiduuidGive this instance of button a custom ID, or keep the default.stringuuidv4()
variantvariantSet the variant of the button"primary" | "secondary" | "tertiary"'primary'

CSS Custom Properties

NameDescription
--background-colorDEPRECATED: kept for backwards compatibility, but will be removed by August 2024
--background-color-primaryDEPRECATED: kept for backwards compatibility, but will be removed by August 2024
--background-color-secondaryDEPRECATED: kept for backwards compatibility, but will be removed by August 2024
--background-color-tertiaryDEPRECATED: kept for backwards compatibility, but will be removed by August 2024
--border-widthDEPRECATED: kept for backwards compatibility, but will be removed by August 2024
--button-background-colorSet the background color.
--button-background-color-hoverSet the background color on hover
--button-background-color-pressedSet the background color on press
--button-background-color-primarySet the primary background color.
--button-background-color-secondarySet the secondary background color.
--button-background-color-tertiarySet the tertiary background color.
--button-border-colorSet the border color of the anchor-button
--button-border-widthSet the border width of the anchor-button
--button-bottom-left-radiusSet the bottom-left radius of the button.
--button-bottom-right-radiusSet the bottom-right radius of the button.
--button-gap-icon-textSet the gap between icon and text.
--button-icon-colorSet the icon color.
--button-line-heightSet the line height.
--button-text-colorSet the text color.
--button-top-left-radiusSet the top-left radius of the button.
--button-top-right-radiusSet the top-right radius of the button.
--button-widthSet the width.
--gap-icon-textDEPRECATED: kept for backwards compatibility, but will be removed by August 2024
--icon-colorDEPRECATED: kept for backwards compatibility, but will be removed by August 2024
--line-heightDEPRECATED: kept for backwards compatibility, but will be removed by August 2024
--text-colorDEPRECATED: kept for backwards compatibility, but will be removed by August 2024
--widthDEPRECATED: kept for backwards compatibility, but will be removed by August 2024

Dependencies

Depends on

Graph

graph TD;
  anchor-button --> anchor-spinner
  anchor-button --> anchor-icon
  style anchor-button fill:#f9f,stroke:#333,stroke-width:4px

On this page