Button
Buttons are used primarily for actions, such as "add", "close", "cancel" or "save". They always have a label and optionally contain one icon, before or after the label.
Example
Usage Rules
Do:
- Label the button to explain what it does
- Keep lables as concise as possible
- Keep button sequence consistent, for example keeping Cancel/OK in the same order product wide
Don’t:
- Use multiple Primary buttons in the same segment
Variants
Disabled
Feedback
We have 4 feeback variant: info
, positive
, warning
and negative
.
Every feedback variant has a primary and secondary variants.
Highlighted Button
We have a tertiary button variant which can be accessed through isHighlighted
prop.
Icon
Every button can be rendered with an icon to emphasize an action. All available icons can be found here.
Kind
Buttons come in four semantic variants: primary
, secondary
, tertiary
, negative
and dark
.
Use the Primary Button for the main action option the user will take. Avoid using more than one Primary Button in the same segment. Remember to use buttons in their proper hierarchy of importance.
Use the Floating Button for when you need the button to be floating above other elements. Floating Button has a fixed
position by default and it's been overwritten in example to relative
to be visible in the related section.
Loader
Every button can be rendered with a loader to emphasize loading state.
Loader supports all sizes and can be placed on left or right of the Button using iconAlignment
prop.
Sizes
The Button
component is available in three sizes: small
, medium
and large
.
Use multiple sizes sparingly to avoid visual clutter.
URL Navigation
This can be done by injecting the Link component from react-router-dom
to the Button
component and passing the required to
prop for navigating to a route.
info
The Button
is not rendered here because the react-router-dom
package is needed for URL naviagtion. This is just an example for how it will be used for URL naviagtion.
import { Link } from 'react-router-dom';
<>
<Button to="/hello-world" as={Link} label="Link button" kind="primary" />
</>;
Props
Name | Type | Default |
---|---|---|
label * The label for the button |
| — |
id Native HTML attribute: Link . |
| — |
type Native HTML attribute: Link |
| — |
isHighlighted isHighlighted boolean for Highlighted tertiary button |
| — |
size Size of the button |
| — |
onMouseLeave Native HTML callback: Link |
| — |
onMouseEnter Native HTML callback: Link |
| — |
onFocus Native HTML callback: Link |
| — |
onClick Native HTML callback: Link |
| — |
onBlur Native HTML callback: Link |
| — |
onKeyDown Native HTML callback: Link |
| — |
kind Kind of the button | "negative" | "primary" | "secondary" | "tertiary" | "dark" | "floating" | "feedback-info-primary" | ... | — |
iconName Name of the Icon that is shown next to the label. Refer to the full list here: Link | "AddValue" | "AppGrid" | "ArrowCircleLeft" | "ArrowCircleRight" | "ArrowDown" | "ArrowDownLeft" | "A... | — |
iconAlignment Whether the icon should appear after or before the label |
| — |
disabled Use this prop if the component should not be interactive |
| — |
aria-pressed Optional aria-pressed prop for accessibility |
| — |
isLoading Boolean prop to add a loader to the component |
| — |
css Add custom styles to this component. Use with caution. Learn more here: Link |
| — |
inputFieldCss |
| — |
as Root node to use for Button component |
| — |
data-{foo} Data attributes can be used by testing libraries to retrieve components or assert their existence |
| — |
* - the prop is required. |