Use default buttons for most actions that aren't the main call to action for a page or area. Default
buttons are less prominent than primary buttons.
import React from 'react';
import Button from '@atlaskit/button/default/button';
export default function ButtonDefaultExample(): React.JSX.Element {
return <Button>Default button</Button>;
}
Appearance
Primary
Use a primary button to call attention to a form submission or to highlight the
most important call to action on a page. Primary buttons should only appear once per area, but not
every screen needs a primary button.
The placement of the primary button typically matches the alignment of the button(s) in the layout.
Review
usage details for alignment examples.
Subtle
Use a subtle button with a primary button for secondary actions.
Subtle buttons are best used in spaces where it's already clear items can be interacted with, like
toolbars or groups of buttons next to each other. Avoid using them in other situations, as they
aren't as obviously clickable as other button styles.
Set isDisabled to disable a button that shouldn't be actionable. The button will appear faded and
won't respond to user interaction.
Disabled buttons can cause accessibility issues (disabled elements are not in the tab order) so
wherever possible, avoid using isDisabled. Instead, use validation or
other techniques to show users how to proceed.
import React from 'react';
import Button from '@atlaskit/button/default/button';
export default function ButtonDisabledExample(): React.JSX.Element {
return (
<Button appearance="primary" isDisabled>
Disabled button
</Button>
);
}
Selected
Set isSelected to indicate the button is selected.
When a button is still loading and not actionable, a loading spinner can be displayed in place of
the button label. This also disables the button and blocks user interaction.
Buttons can expand to full width to fill the parent container. This is sometimes done in login
forms. Follow the alignment guidance for more
options.
import React from 'react';
import Button from '@atlaskit/button/default/button';
const ButtonFullWidthExample = (): React.JSX.Element => {
return (
<Button shouldFitContainer appearance="primary">
Full width button
</Button>
);
};
export default ButtonFullWidthExample;
Button with icon
Buttons may include an icon before or after the text label. For an icon-only button, see
icon button.
Icon before
Display an icon before the text.
import React from 'react';
import Button from '@atlaskit/button/default/button';
import StarStarredIcon from '@atlaskit/icon/core/star-starred';
const ButtonIconBeforeExample = (): React.JSX.Element => {
return (
<Button iconBefore={StarStarredIcon} appearance="primary">
Icon before
</Button>
);
};
export default ButtonIconBeforeExample;
Icon after
Display an icon after the text.
import React from 'react';
import Button from '@atlaskit/button/default/button';
import StarIcon from '@atlaskit/icon/core/star-starred';
export default function ButtonIconAfterExample(): React.JSX.Element {
return (
<Button iconAfter={StarIcon} appearance="primary">
Icon after
</Button>
);
}
Overriding icon props
Use the iconBefore or iconAfter render prop to override the default icon props.
import React from 'react';
import Button from '@atlaskit/button/default/button';
import WarningIcon from '@atlaskit/icon/core/status-warning';
import { token } from '@atlaskit/tokens';
const ButtonIconOverrideExample = (): React.JSX.Element => {
return (
<Button
iconBefore={(iconProps) => (
<WarningIcon {...iconProps} size="small" color={token('color.icon.warning')} />
)}
appearance="warning"
>
Icon with overrides
</Button>
);
};
export default ButtonIconOverrideExample;
Truncation
Avoid truncation whenever possible. Make sure there's always a way to access the full content for
all users.
Text will truncate when buttons are in a narrow container to prevent wrapping onto a new line and
breaking layouts. An ellipsis will be added to the end to indicate that the text has been truncated.
The truncation is implemented with styles, so screen readers will still read the full text.