Buttons

The button base component provides a set of classes to style buttons consistently across your application. It includes various states and modifiers to handle different button types and interactions.

The button component is meant to be used on a <button> or <a> element, but can be applied to anything.

Base class

The .button class is the base class for all button styles.

html
<button type="button" class="button">Click me!</button>

Variants

There are 4 button variants provided by default: .primary, .secondary, .tertiary, and .link.

html
<button type="button" class="button primary">Primary Button</button>

<button type="button" class="button secondary">Secondary Button</button>

<button type="button" class="button tertiary">Tertiary Button</button>

<button type="button" class="button link">Link Button</button>

Custom Properties

The following custom properties can be used to customize the button component:

PropertyDescriptionDefault Value
--graupl-button-min-widthThe minimum width of the button component.var(--graupl-interactive-min-width)
--graupl-button-min-heightThe minimum height of the button component.var(--graupl-interactive-min-height)
--graupl-button-padding-xThe horizontal padding of the button component.var(--graupl-spacer-5)
--graupl-button-padding-yThe vertical padding of the button component.var(--graupl-spacer-3)
--graupl-button-paddingThe padding of the button component (combines x and y padding)var(--graupl-button-padding-x) var(--graupl-button-padding-y)
--graupl-button-font-sizeThe font size of the button component.var(--graupl-font-size-base)
--graupl-button-transitionThe transition of the button component.background var(--graupl-transition-duration-fast), color var(--graupl-transition-duration-fast), transform var(--graupl-transition-duration-fast)
--graupl-button-transition-reduced-motionThe transition of the button component when reduced motion is enabled.background var(--graupl-transition-duration-none), color var(--graupl-transition-duration-none)
--graupl-button-transformThe transform of the button component.0
--graupl-button-visited-transformThe transform of a visited button component.var(--graupl-button-transform)
--graupl-button-focus-transformThe transform of a focused button component.var(--graupl-button-transform)
--graupl-button-hover-transformThe transform of a hovered button component.var(--graupl-button-transform)
--graupl-button-active-transformThe transform of an active button component.scale(0.95)
--graupl-button-disabled-transformThe transform of a disabled button component.0
--graupl-button-backgroundThe background colour of the button component.var(--graupl-background)
--graupl-button-visited-backgroundThe background colour of a visited button component.var(--graupl-button-background)
--graupl-button-focus-backgroundThe background colour of a focused button component.var(--graupl-button-background)
--graupl-button-hover-backgroundThe background colour of a hovered button component.var(--graupl-color)
--graupl-button-active-backgroundThe background colour of an active button component.var(--graupl-button-hover-background)
--graupl-button-disabled-backgroundThe background colour of a disabled button component.var(--graupl-background)
--graupl-button-colorThe text colour of the button component.var(--graupl-color)
--graupl-button-visited-colorThe text colour of a visited button component.var(--graupl-button-color)
--graupl-button-focus-colorThe text colour of a focused button component.var(--graupl-button-color)
--graupl-button-hover-colorThe text colour of a hovered button component.var(--graupl-background)
--graupl-button-active-colorThe text colour of an active button component.var(--graupl-button-hover-color)
--graupl-button-disabled-colorThe text colour of a disabled button component.var(--graupl-theme-active--primary--200)
--graupl-button-border-top-widthThe top border width of the button component.var(--graupl-border-top-width)
--graupl-button-border-right-widthThe right border width of the button component.var(--graupl-border-right-width)
--graupl-button-border-bottom-widthThe bottom border width of the button component.var(--graupl-border-bottom-width)
--graupl-button-border-left-widthThe left border width of the button component.var(--graupl-border-left-width)
--graupl-button-border-widthThe border width of the button component (combines top, right, bottom, and left widths)var(--graupl-button-border-top-width) var(--graupl-button-border-right-width) var(--graupl-button-border-bottom-width) var(--graupl-button-border-left-width)
--graupl-button-border-top-styleThe top border style of the button component.var(--graupl-border-top-style)
--graupl-button-border-right-styleThe right border style of the button component.var(--graupl-border-right-style)
--graupl-button-border-bottom-styleThe bottom border style of the button component.var(--graupl-border-bottom-style)
--graupl-button-border-left-styleThe left border style of the button component.var(--graupl-border-left-style)
--graupl-button-border-styleThe border style of the button component (combines top, right, bottom, and left styles)var(--graupl-button-border-top-style) var(--graupl-button-border-right-style) var(--graupl-button-border-bottom-style) var(--graupl-button-border-left-style)
--graupl-button-border-top-left-radiusThe top left border radius of the button component.var(--graupl-border-top-left-radius)
--graupl-button-border-top-right-radiusThe top right border radius of the button component.var(--graupl-border-top-right-radius)
--graupl-button-border-bottom-right-radiusThe bottom right border radius of the button component.var(--graupl-border-bottom-right-radius)
--graupl-button-border-bottom-left-radiusThe bottom left border radius of the button component.var(--graupl-border-bottom-left-radius)
--graupl-button-border-radiusThe border radius of the button component (combines top-left, top-right, bottom-right, and bottom-left radii)var(--graupl-button-border-top-left-radius) var(--graupl-button-border-top-right-radius) var(--graupl-button-border-bottom-right-radius) var(--graupl-button-border-bottom-left-radius)
--graupl-button-border-colorThe border colour of the button component.var(--graupl-border-color)
--graupl-button-visited-border-colorThe border colour of a visited button component.var(--graupl-button-border-color)
--graupl-button-focus-border-colorThe border colour of a focused button component.var(--graupl-button-border-color)
--graupl-button-hover-border-colorThe border colour of a hovered button component.var(--graupl-border-color)
--graupl-button-active-border-colorThe border colour of an active button component.var(--graupl-button-hover-border-color)
--graupl-button-disabled-border-colorThe border colour of a disabled button component.var(--graupl-theme-active--primary--200)

Sass variables

The following Sass variables can be used to customize the generation of the button component:

VariableDescriptionDefault Value
$selector-baseThe selector base for the component..
$modifier-selector-baseThe selector base for component modifiers..
$button-selector-baseThe selector base for the button component..
$button-selectorThe button component selector.button
$button-link-selector-baseThe selector base for the button link component modifier..
$button-link-selectorThe button link component modifier selector.link
$button-theme-selector-baseThe selector base for the button theme component modifiers..
$button-theme-selector-prefixThe button theme component modifier selector prefix.""
$button-initial-transformThe initial transform of the button.none
$button-final-transformThe final transform of the button.scale(0.95)
$button-disabled-transformThe disabled transform of the button.none
$custom-button-state-theme-mapA map of custom button state theme values.()