Summary

Use buttons as triggers for actions that are used in forms, toolbars, dialog footers and as stand-alone action triggers. Try to avoid the usage of buttons for navigation. The main difference between actions and navigation is that Actions are operations performed on objects, while Navigation refers to elements on the screen or view that take you to another context in the application.

Status

API status: general
Web resource key: com.atlassian.auiplugin:aui-button
AMD Module key: require('aui/button')
Experimental API: 4.2
General API: 5.1

Examples

Button types

Button variations

These variations can be used against all button types. For button groups on your page, only choose one type of variation, do not mix them.

deprecated

Busy buttons

Code

HTML

The base button code is:

You can then apply a button type by adding the appropriate class, for example aui-button-primary:

Button types and classes

  • Standard/default - (no extra class)
  • Primary - aui-button-primary
  • Link-style (used for "cancel" actions) - aui-button-link
    • with icon and text - aui-button-link aui-button-link-icon-text
  • Subtle (looks like a link while inactive, looks like a button when hovered/focused) - aui-button-subtle

Customising the state

The AUI button uses three CSS variables to control the colours used in a given state:

--aui-btn-bg
The button's background colour
--aui-btn-border
The button's border colour
--aui-btn-text
The button's text colour

In addition, the AUI theme defines CSS variables on the :root element for each button type's base and pseudo-states.

Button states

Button states are applied using boolean ARIA attributes:

States:

  • Disabled: Buttons provides the disabled style but you still need to disable the events - aria-disabled="true".
  • Pressed: A pressed/enabled style for toggle buttons - aria-pressed="true"

Note: The style applies when the attribute is present and set to true.

Button groups

Create a button group by wrapping buttons in an aui-buttons (note plural) DIV element:

Split buttons

Require a wrapper and extra modifier classes; the second button should always be a Dropdown2 trigger:

Read the Dropdown menu component documentation for more details on how to control the rendering and behaviour of the dropdown menu.

Soy

Single button

Dropdown 2 button

Icon button

Grouped buttons

Split buttons

Disabled buttons

Pressed buttons

Link buttons with icon and text

A11Y guidelines

Side note: whether you'd follow these guidelines or not, it's always advised to at least test your markup with a screen reader software.

  • Avoid using other HTML tags than button or input if possible.
    • If you're creating a custom button (again! not advised!) ensure role="button", tabindex="0", and all expected keyboard support is present.
  • When using icons inside buttons
    • Make sure the icon has aria-hidden="true" applied to it.
    • Don't add additional text into the icon's span.
    • If this is an icon-only button, please add aria-label attribute to the button, provide descriptive and unique text.
  • In case of multiple buttons with similar purpose on a page (e.g. "edit" button on each item in a list), specify descriptive text (e.g. "Edit Profile 1”) via the aria-label or aria-labelledby attributes to make the detailed information available for screen reader users.
    Examples: