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 <button> or <a> elements, but can be applied to anything.

Base class

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

Variants

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

Select the button variant you would like displayed.

If you are compiling your own version of Graupl, you can set the $themeable variable to false to disable variants.

States

Buttons handle the following states by default: visited, focus, hover, active, disabled, selected, and current (though not all will have visual differences out-of-the-box).

You can manually apply these states with the helper classes .visited, .focus, .hover, .active, .disabled, .selected, and .current respectively.

Select the button state you would like displayed.

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.44px
--graupl-button-min-heightThe minimum height of the button component.44px
--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-y) var(--graupl-button-padding-x)
--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) var(--graupl-transition-timing-function), color var(--graupl-transition-duration-fast) var(--graupl-transition-timing-function), transform var(--graupl-transition-duration-fast) var(--graupl-transition-timing-function)
--graupl-button-transition-reduced-motionThe transition of the button component when reduced motion is enabled.background var(--graupl-transition-duration-none) var(--graupl-transition-timing-function), color var(--graupl-transition-duration-none) var(--graupl-transition-timing-function)
--graupl-button-transformThe transform of the button component.none
--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.none
--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."."
$generate-base-theme-mapA flag to generate the base theme maps for button variants.true
$themeableA flag that determines whether theme modifiers are generated.true
$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
$button-theme-mappingsA map of properties and color shades used generate all button variants.()
$button-theme-mapA map of all properties, colors, and color shades used to generate all button variants.()