Button

Buttons provide cues for actions and events. These fundamental components allow users to process actions or navigate an experience.

When to use

When a person:

  • submits a form,
  • starts a new task / action.

The Button component has 4 different variant variants: primary, secondary, tertiary, and minimal.

Primary buttons are intended to be used as the leading trigger or cue of action. Primary buttons are bold with a dominant color background and white text/icons. These are to be used sparingly as the sole action of a view. Primary buttons can be accompanied by secondary button to balance action hierarchy.

Secondary buttons should be used in combination with a primary button as a way to create action hierarchy. Secondary buttons are subdued in value with the primary color text to compliment the primary buttons.

Tertiary buttons can used as a substitute for a secondary buttons, but should never take the role of a primary button action. As the name implies, it’s offered to supplement to create variation within an experience.

Examples

Button Variants

Primary
Secondary
Tertiary
Minimal
Active
Disabled
Loading

Button Intents

Default
Success
Warning
Error
AI

Button Sizes

Shapes

Full Width Buttons

Adding enhancers

Button with dropdown menu button

As an anchor

Visit the Styletron docs

API

Button props

NameTypeDefaultDescription
animate
boolean
falseEnable animation for certain parts of button. e.g. shows animated border on hover for ai intent
children
react node
Visible label.
disabled
boolean
falseIndicates that the button is disabled
endEnhancer
function
A component rendered at the end of the button.
fullWidth
boolean
falseGives full width to button
intent
'default' | 'success' | 'warning' | 'error' | 'ai'
defaultDefines the intent of the button.
isLoading
boolean
falseShow loading button style and spinner.
isSelected
boolean
falseIndicates that the button is selected.
onClick
function
Function called when button is clicked.
overrides
custom
Lets you customize all aspects of the component.
shape
'default' | 'square' | 'pill'
defaultDefines the shape of the button.
size
'xxs' | 'xs' | 'sm' | 'md' | 'lg'
Defines the size of the button. SPACIOUS | COMFORTABLE -> md, COMPACT -> xxxs, DEFAULT -> md
startEnhancer
function
A component rendered at the start of the button.
tooltipContent
react node
The content of the tooltip. If provided, Button will be wrapped with StatefulTooltip.
variant
'primary' | 'secondary' | 'tertiary' | 'minimal'
primaryDefines the kind (purpose) of a button.

You can check the implementation of the component for more details.

Button exports

You can import this module like so:

import {Button} from 'spaceweb/button'

It exports the following components or utility functions:

  • Button
  • IconButton
  • IconTextButton
  • StyledEndEnhancer
  • StyledLoadingSpinnerContainer
  • StyledStartEnhancer