Overview
Button is a branded component to convey call to action. Part of the Bolt “Components” CSS framework that powers the Bolt Design System.
Install via NPM
npm install @bolt/components-button
Description
Buttons are the core of our action components. Their affordance is immediate and can be use for most actions and allow users to access the target with a single interaction. Buttons clearly provide a next step for the user.
Our Buttons depend on the theme they are contained in and change in appearance based on said theme. The themes and button colors were designed together to ensure the proper amount affordance and clarity.
Xlight and light themes
- Primary: Light Indigo container with white text
- Secondary: white button with indigo text
- Text button: Light indigo text with chevron
Dark and xdark themes
- Primary: Yellow container with default indigo text
- Secondary: white button with indigo text
Text button: white text with chevron
Currently only have one defined size (though other options can and will be defined in the future)
- Can be 100% width of the wrapper for mobile or card instances
- Can optionally be 100% width. For example, the button has default width of 2 rem on either side on larger screens but full width on smaller screens
Dos
- CTAs must be clearly and succinctly labeled with a next step
- CTA should lead with strong action verbs
- The primary CTA should be the most important action.
- Be consistent in placement based on the screen size and device
- Fall back to the text button in secondary and tertiary content areas where you can. For example, cards with a button use the text style so that a filled button doesn't become overwhelming and redundant.
- Follow theming rules
Don'ts
- Don't clutter the page with too many buttons
- Don't mix and match themes and their button colors. For example, do not use the indigo button on dark and xdark themes as the indigo button does not stand out enough.
- Don't mix and match colors outside the theme, see button groups.
Usage
{% include "@bolt-components-button/button.twig" with {
text: "This is a button"
} only %}
Schema
Note: when assigning component props as HTML attributes on a web component, make sure to use kebab-case
.
Prop Name | Description | Type | Default Value | Option(s) |
---|---|---|---|---|
|
A Drupal-style attributes object with extra attributes to append to this component. |
object
| — |
|
|
Text inside the button. |
string
| — |
|
|
Transforms the button text to various cases. |
string
|
none
|
|
|
Determines the button tag type for semantic buttons |
string
| — |
|
|
Size of the button. |
string
|
medium
|
|
|
Style of the button determined by information hierarchy. |
string
|
primary
|
|
|
Controls the width of the button. |
string
|
auto
|
|
|
Rounds the corners of the button. |
string
|
regular
|
|
|
Horizontal alignment of items (text and icon) inside the button. Note: the values left and right are deprecated, use start and end instead. |
string
|
center
|
|
|
Icon data as expected by the icon component. Accepts an additional position prop that determines placement within the button. |
object
| — |
|
|
Make the button to display only the icon and hide the text (which is still required). You are required to pass both text and icon data for this option to work. |
boolean
|
false
|
|
|
Use the align parameter instead. |
| — |
|
|
Use the border_radius parameter instead. |
| — |
|
|
Switch to using the new type prop instead. |
string
|
button
|
|