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.
API status: | general |
---|---|
Included in AUI core? | Yes. You do not need to explicitly require the web resource key. |
Web resource key: |
com.atlassian.auiplugin:aui-buttons
|
AMD Module key: |
require('aui/button')
|
Experimental API: | 4.2 |
General API: | 5.1 |
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.
You can add a spinner to an AUI Button by setting the button's busy
property to true
.
<button class="aui-button" id="button-spin-1">Do Something</button>
<button class="aui-button aui-button-primary" id="button-spin-2">Do Something</button>
AJS.$(document).on('click', '#button-spin-1, #button-spin-2', function() {
var that = this;
if (!that.isBusy()) {
that.busy();
setTimeout(function() {
that.idle();
}, 2000);
}
});
The base button code is:
<button class="aui-button">Button</button>
You can then apply a button type by adding the appropriate class, for example aui-button-primary
:
<button class="aui-button aui-button-primary">Button</button>
aui-button-primary
aui-button-link
aui-button-subtle
Button states are applied using boolean ARIA attributes:
<button class="aui-button" aria-disabled="true" disabled>Button</button>
<button class="aui-button" aria-pressed="true">Button</button>
States:
aria-disabled="true"
.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:
<div class="aui-buttons">
<button class="aui-button">Button</button>
<button class="aui-button">Button</button>
<button class="aui-button">Button</button>
</div>
Split buttons
Require a wrapper and extra modifier classes; the second button should always be a Dropdown2 trigger:
<div class="aui-buttons">
<button class="aui-button aui-button-split-main">Split main</button>
<button class="aui-button aui-dropdown2-trigger aui-button-split-more" aria-controls="split-container-dropdown">Split more</button>
</div>
<!-- Be sure to put your dropdown markup outside the button group...
otherwise the buttons will get jaggy edges! -->
<aui-dropdown-menu id="split-container-dropdown">
<aui-item-link>Menu item 1</aui-item-link>
<aui-item-link>Menu item 2</aui-item-link>
<aui-item-link>Menu item 3</aui-item-link>
</aui-dropdown-menu>
Note: Use the Dropdown2's data-container
feature to force the dropdown to extend right to left by setting the container with an ID on the aui-buttons
element.
{call aui.buttons.button}
{param text: 'Button'/}
{/call}
{call aui.buttons.button}
{param text: 'Primary Button'/}
{param type: 'primary'/}
{/call}
{call aui.buttons.button}
{param text: 'Dropdown button'/}
{param type: 'link'/}
{param dropdown2Target: 'dropdown2id'/}
{/call}
{call aui.buttons.button}
{param text: ' Icon Button' /}
{param iconType: 'aui' /}
{param iconClass: 'aui-icon-small aui-iconfont-view' /}
{param iconText: 'View' /}
{/call}
{call aui.buttons.buttons}
{param content}
{call aui.buttons.button}{param text: 'Button'/}{/call}
{call aui.buttons.button}{param text: 'Button'/}{/call}
{call aui.buttons.button}{param text: 'Button'/}{/call}
{/param}
{/call}
{call aui.buttons.buttons}
{param content}
{call aui.buttons.splitButton}
{param splitButtonMain: [
'text': 'Split main'
] /}
{param splitButtonMore: [
'text': 'Split more',
'dropdown2Target': 'split-container-dropdown'
] /}
{/call}
{/param}
{/call}
{call aui.buttons.button}
{param text: 'Button'/}
{param isDisabled: 'true'/}
{/call}
{call aui.buttons.button}
{param text: 'Button'/}
{param isPressed: 'true'/}
{/call}