Form

Button

A button draws attention to an important action and initializes this action when clicked.
1
import {Button, showNotification} from '@coveord/plasma-mantine';
2
3
const Demo = () => <Button onClick={() => showNotification({message: 'Button clicked'})}>Default button</Button>;
4
export default Demo;

Props

NameTypeDefaultDescription
childrenReactNode
Button label
colorMantineColor
Button color from theme
compactboolean
Reduces vertical and horizontal spacing
disabledboolean
Disabled state
disabledTooltipstring
The tooltip message to display when disabled
disabledTooltipPropsOmit<TooltipProps, "disabled" | "label" | "children">
Additional tooltip props to set on the disabled button tooltip
fullWidthboolean
Sets button width to 100% of parent element
gradientMantineGradient
Controls gradient settings in gradient variant only
leftIconReactNode
Adds icon before button label
loaderPosition"left" | "right" | "center"
Loader position relative to button label
loaderPropsLoaderProps
Props spread to Loader component
loadingboolean
Indicate loading state
onClickMouseEventHandler<HTMLButtonElement>
radiusMantineNumberSize
Key of theme.radius or any valid CSS value to set border-radius, theme.defaultRadius by default
rightIconReactNode
Adds icon after button label
sizeMantineSize
Predefined button size
type"button" | "submit" | "reset"
Button type attribute
uppercaseboolean
Set text-transform to uppercase
variantVariants<"filled" | "outline" | "light" | "white" | "default" | "subtle" | "gradient">
Controls button appearance

Examples

Secondary
1
import {Button, showNotification} from '@coveord/plasma-mantine';
2
3
const Demo = () => (
4
<Button variant="outline" onClick={() => showNotification({message: 'Button clicked'})}>
5
Secondary button
6
</Button>
7
);
8
export default Demo;
Disabled
1
import {Button} from '@coveord/plasma-mantine';
2
3
const Demo = () => (
4
<Button disabled disabledTooltip="This button is disabled" onClick={() => alert('button clicked')}>
5
Disabled button
6
</Button>
7
);
8
export default Demo;
Async click handler
1
import {Button, showNotification} from '@coveord/plasma-mantine';
2
import {CheckmarkSize24Px} from '@coveord/plasma-react-icons';
3
4
const somethingAsync = (ms: number) => new Promise((r) => setTimeout(r, ms));
5
6
const promise = async () => {
7
await somethingAsync(3000);
8
showNotification({
9
title: 'Saved successfully',
10
message: 'The save disabled was put in a loading state while it was waiting for the save to resolve.',
11
autoClose: false,
12
icon: <CheckmarkSize24Px height={24} />,
13
color: 'success',
14
});
15
};
16
17
const Demo = () => <Button onClick={promise}>Save</Button>;
18
export default Demo;

Best Practices

The button label should allow users to foresee what will happen when clicking them.

Avoid multiplying buttons within a page. A page should have only one primary action button. If several secondary action buttons are required, consider using actionable items instead.

Labeling

Keep labels short, preferably under three words. Use trigger words to clearly indicate the action performed by the button. A trigger word is typically a verb that influences users into clicking due to its specificity. For example, use "View profile" rather than "Open profile", and "Create playlist" rather than "Save".

The first word of the label should be a verb. If adding a noun is required for context, avoid including an article. For example, write "Add filter" rather than "Add a filter", but write "Save" and "Cancel".

When using a button to have users confirm the action to execute, use an active word to clearly state the resulting action. For instance, if users must confirm the deletion of a file, write "Delete" and "Cancel" rather than "Yes" and "No".

Order of Buttons

When using a group of related buttons, such as for the "Save" and "Cancel" actions, always put the primary button to the right and the secondary to the left of the primary button.

In such case, the primary button must correspond to an action that moves the user forward through their journey or to the main action that the user should take.

For example, in the Sticky footer of a page where the user edits a configuration, order buttons as follows: "Cancel" (secondary), then "Save" (primary).

Similarly, in the footer of a modal wizard, navigation buttons must be ordered as follows: "Previous" (secondary), then "Next" (primary). At the last step, the “Next” button must be replaced with a primary button with a label indicating the resulting action. For example, an appropriate label would be “Add filter” rather than “Save”.

In a page header, the primary button should appear on the left and the secondary button should be to the right of the primary button. The primary action usually relates to the creation of new elements, while secondary actions are usually used to trigger troubleshooting or management actions, such as activity review. If multiple secondary actions are required, group them using an actionable item on the rightmost side of the header.

Variants

TypePurpose
PrimaryA primary button draws the users' attention to the main action. There should be only one primary button per section or page.
SecondaryA secondary button triggers an action of lesser importance. Multiple secondary buttons may trigger actions of similar importance.
Icon + labelAdd a icon left of the label to clarify the action or draw attention to the button. Ensure the icon is highly recognizable.
Label + iconAdd an icon right of the label to indicate that additional options are available when clicking the button. This indicates that clicking the button doesn't immediately trigger the action. Instead, a menu overlay is displayed, allowing users to select the exact action to be performed. For example, use a label and an icon on the right when the action is "Create" and options are to create from a template or a blank file.
Icon onlyWhen space is an issue or when the icon is highly and instantly recognizable, an icon alone may suffice. For instance, the "Settings" button is commonly presented using a cog icon. However, you should never use an icon-only button for primary actions.
Append and prepend separatorAdding a separator is an aesthetic choice typically made when multiple buttons are stacked vertically. Use a separator to align the icon to the right or left of the button. All buttons must have the same width when vertically stacked.

Feedback and Validation

When the label is hidden, add a tooltip displaying the action.

Related Components

If your use case doesn't match the guidelines above, consider using one of the following components instead:

  • Link - When you need to redirect users to another section or website.
  • Actionable items - When you need to group several less important actions together.
Edit guidelines