Backpack UI
Components
Button

Button

Buttons allow users to take actions with a click or tap. They can return either a button element with an onClick event or an anchor element with an href.


_10
import {
_10
Button,
_10
ButtonGroup,
_10
} from '@ef-global/backpack/Button'

Variants

Three core variants of buttons are available: Primary, Secondary, and Link. All of them accept various modifiers as documented below. In the examples below we are wrapping the buttons in a <ButtonGroup> to ensure the correct layout.

Primary

The primary button denotes the main action available to the user in any view. It can be set using the variant prop, but is also the default if nothing is passed.



_10
<ButtonGroup>
_10
<Button as={'button'} variant="primary">Primary</Button>
_10
<Button as={'button'} variant="primary" disabled>Disabled</Button>
_10
</ButtonGroup>

Secondary

The secondary button can be used alongside the primary for less important actions.



_10
<ButtonGroup>
_10
<Button as={'button'} variant="secondary">Primary</Button>
_10
<Button as={'button'} variant="secondary" disabled>Disabled</Button>
_10
</ButtonGroup>

Link

Finally, the link style button can be used for even less important actions or more minimal UIs.



_10
<ButtonGroup>
_10
<Button as={'button'} variant="link">Primary</Button>
_10
<Button as={'button'} variant="link" disabled>Disabled</Button>
_10
</ButtonGroup>

Mono buttons

If your UI clashes with the Primary button color, you can also set its mono prop to 'light' or 'dark' depending on the background. This works for all button variants.

Mono light



_10
<ButtonGroup>
_10
<Button as={'button'} variant="primary" mono="light">Primary</Button>
_10
<Button as={'button'} variant="secondary" mono="light">Secondary</Button>
_10
<Button as={'button'} variant="link" mono="light">Link</Button>
_10
</ButtonGroup>

Mono dark



_10
<ButtonGroup>
_10
<Button as={'button'} variant="primary" mono="dark">Primary</Button>
_10
<Button as={'button'} variant="secondary" mono="dark">Secondary</Button>
_10
<Button as={'button'} variant="link" mono="dark">Link</Button>
_10
</ButtonGroup>

Shape

The buttons' shape prop allows you to set the correct shape.

Round

The 'round' modifier ensures that single-icon buttons appear as circles.



_10
<ButtonGroup>
_10
<Button as={'button'} variant="primary" shape="round"><IconArrowDown /></Button>
_10
<Button as={'button'} variant="secondary" shape="round"><IconArrowDown /></Button>
_10
<Button as={'button'} variant="link" shape="round"><IconArrowDown /></Button>
_10
</ButtonGroup>

Square

The 'square' modifier makes buttons more rectangular. It's useful for product UIs or when you need to pack more buttons in a row.



_10
<ButtonGroup>
_10
<Button as={'button'} variant="primary" shape="square">Square <IconArrowDown /></Button>
_10
<Button as={'button'} variant="secondary" shape="square">Square <IconArrowDown /></Button>
_10
<Button as={'button'} variant="link" shape="square">Square <IconArrowDown /></Button>
_10
</ButtonGroup>

Sizes

Buttons are currently available in two sizes: regular or small. The size can be set with the size prop.

Regular (default)



_10
<ButtonGroup>
_10
<Button as={'button'} variant="primary" size="regular">Primary <IconArrowDown /></Button>
_10
<Button as={'button'} variant="secondary" size="regular">Secondary <IconArrowDown /></Button>
_10
<Button as={'button'} variant="link" size="regular">Link <IconArrowDown /></Button>
_10
</ButtonGroup>

Small



_10
<ButtonGroup>
_10
<Button as={'button'} variant="primary" size="small">Primary <IconArrowDown /></Button>
_10
<Button as={'button'} variant="secondary" size="small">Secondary <IconArrowDown /></Button>
_10
<Button as={'button'} variant="link" size="small">Link <IconArrowDown /></Button>
_10
</ButtonGroup>

As

By default the Button will return an html button element which you can add an onClick event to.

Button (default)



_10
<ButtonGroup>
_10
<Button as="button" variant="primary" onClick={action}>Primary</Button>
_10
<Button as="button" variant="secondary" onClick={action}>Secondary</Button>
_10
<Button as="button" variant="link" onClick={action}>Link</Button>
_10
</ButtonGroup>

Anchor

If you want to use the button to link to another page, set as to 'a' and pass in an href.



_10
<ButtonGroup>
_10
<Button as="a" variant="primary" href="https://google.com">Primary <IconExternalLink /></Button>
_10
<Button as="a" variant="secondary" href="https://google.com">Secondary <IconExternalLink /></Button>
_10
<Button as="a" variant="link" href="https://google.com">Link <IconExternalLink /></Button>
_10
</ButtonGroup>

Theming

By default the buttons inherit your theme's --color-system-primary-accessible variable. Just setting this one variable handles the colouring of all buttons. Buttons are also themeable using specific button color component variables:

Variables


NameDescriptionDefault
--color-system-primary-accessibleAll buttons color themehsl(209, 100%, 44%)
--color-component-button-primary-bgPrimary button background--color-system-primary-accessible
--color-component-button-primary-textPrimary button content--color-system-primary-accessible
--color-component-button-secondary-bgSecondary button background--color-system-primary-accessible
--color-component-button-secondary-textSecondary button content--color-system-primary-accessible
--color-component-button-link-bgLink button background--color-system-primary-accessible
--color-component-button-link-textLink button content--color-system-primary-accessible

Inline styles

By overriding the --color-system-primary-accessible variable you can theme all buttons at once.



_10
<ButtonGroup style={{'--color-system-primary-accessible': 'hsl(272 50.0% 45.8%)'}}>
_10
<Button as={'button'} variant="primary">Primary <IconExternalLink /></Button>
_10
<Button as={'button'} variant="secondary">Secondary <IconExternalLink /></Button>
_10
<Button as={'button'} variant="link">Link <IconExternalLink /></Button>
_10
</ButtonGroup>

Or you can modify instances separately as shown below. If using a gradient also set the --color-system-primary-accessible variable to one of the gradient stop colors so the secondary and link buttons fit the theme.



_10
<ButtonGroup>
_10
<Button as={'button'} variant="primary" style={{'--color-component-button-primary-bg': 'hsl(322 75.0% 46.0%)'}}>Primary <IconExternalLink /></Button>
_10
<Button as={'button'} variant="secondary" style={{'--color-component-button-secondary-text': 'hsl(272 50.0% 45.8%)'}}>Secondary <IconExternalLink /></Button>
_10
<Button as={'button'} variant="link" style={{'--color-component-button-link-bg': 'hsl(192 85.0% 31.0%)', '--color-component-button-link-text': 'hsl(192 85.0% 31.0%)'}}>Link <IconExternalLink /></Button>
_10
</ButtonGroup>