Buttons are used to communicate and trigger an action, when interacted with. If the user is being redirected to another page in or outside of the application use a link instead of a button.
Look to Button Patterns (Coming soon!) for best practices regarding button placement on pages, dialogs, tours, and wizards.
There are 4 button variations that we use to differentiate meaning.
Primary
and Default
buttons are used to convey the most important action on a page or dialog. For this reason, they are solid so that it is visually dominant when on a complex page or toolbar.
Primary
button is only to be used to illustrate the end of a major workflow (e.g. Submit Report)Default
button (also called our “workhorse button”) is used to convey action throughout a majority of the experiences.A Create
button is reserved for special use cases where the action is specifically to create something new. There is no muted version of this button.
A Link
button is typically used to convey secondary actions. While buttons links visually look like a text link, they retain the same padding, margin, and expected keyboard trigger behavior as a primary button.
Muted
buttons are used in to convey low priority actions. They should never be used by themselves.
Set the disabled
property to change the button’s state to disabled.
Set the allowFocusOnDisable
property to true
, along with the disabled
property. This allows a button to receive focus when it is disabled by keeping it in the tab cycle. This is good practice for accessibility, as it prevents the button from being hidden from assistive technologies (like screen readers). Further, if allowFocusOnDisable
is true
, then the disabledMessage
and enabledMessage
properties MUST also be set to a localized string. These messages should be such that they help users of accessible technologies understand the button’s state changes.
There are 3 supported button sizes: ‘lg’ (default), ‘md’ and ‘sm’. The large size is recommended for all NUI experiences. Use the size
property to set the appropriate size.
Property | Type | Default | Description |
---|---|---|---|
disabledMessage | String | Required if allowFocusOnDisable is true | A visually hidden hint message to be conveyed to users of assistive technologies like screen readers, when button changes state to disabled. This message should explain why this action is disabled or how to enable it. For example, “This action is restricted to some users” OR “Please fill required fields before submitting” |
enabledMessage | String | Required if allowFocusOnDisable is true | A visually hidden hint message to be conveyed to users of assistive technologies like screen readers, when button changes state to enabled. This message should call out the fact that this action is now enabled. For example, “Press submit to proceed” |
active | Boolean | false | Adds an active class to the button to show active/pressed state. |
allowFocusOnDisable | Boolean | false | Setting this to true allows the button to receive focus when it is disabled. |
children | Node | Collection of React components to be placed in the button. | |
className | String | Custom classes to be added to the <button> tag. | |
disabled | Boolean | false | Controls whether the button is enabled or disabled. |
muted | Boolean | false | Renders the button in an alternate “muted” style where the background color is white and the border color is the brand color for the type. |
nativeHTMLButtonType | String | 'button' | Sets the HTML button type attribute. Options are 'button' , 'reset' , 'submit' . |
size | String | 'lg' | Button size. Options are 'lg' , 'md' , 'sm' . |
type | String | 'default' | Button type. Options are 'primary' , 'default' , 'create' , 'link' . |
Property | Parameters | Description |
---|---|---|
onClick | event | Callback function for onClick events. |