Button (Deprecated)

ui:button

Deprecated as of API version 47.0. We recommend migrating to Lightning Web Components and using the lightning-button component.

For Use In

Lightning Experience, Experience Builder Sites, Salesforce Mobile App, Lightning Out (Beta), Standalone Lightning App

Deprecation Guidelines 

We recommend using Lightning Web Components whenever possible. When migrating to Lightning Web Components, use lightning-button, lightning-button-icon, or lightning-button-icon-stateful. For button groups, use lightning-button-group.

For more information, see Aura Components in the ui Namespace Are Deprecated.

Usage Overview (Deprecated) 

A ui:button component represents a button element that executes an action defined by a controller. To apply Lightning Design System styling, we recommend that you use lightning:button instead of ui:button.

Clicking the button triggers the client-side controller method set for the press event. The button can be created in several ways.

A text-only button has only the label attribute set on it.

1<ui:button label="Find" />

An image-only button uses both the label and labelClass attributes with CSS.

1<!-- Component markup -->
2
3<ui:button label="Find" labelClass="assistiveText" class="img" />
1/** CSS **/
2THIS.uiButton.img {
3  background: url(/path/to/img) no-repeat;
4  width: 50px;
5  height: 25px;
6}

The assistiveText class hides the label from view but makes it available to assistive technologies. To create a button with both image and text, use the label attribute and add styles for the button.

1<!-- Component markup -->
2
3<ui:button label="Find" />
1/** CSS **/
2THIS.uiButton {
3  background: url(/path/to/img) no-repeat;
4}

The previous markup for a button with text and image results in the following HTML.

1<button class="button uiButton--default uiButton" accesskey type="button">
2
3  <span class="label bBody truncate" dir="ltr">Find</span>
4
5</button>

Attributes 

NameDescriptionTypeDefaultRequired
accesskeyThe keyboard access key that puts the button in focus. When the button is in focus, pressing Enter clicks the button.String
bodyThe body of the component. In markup, this is everything in the body of the tag.Aura.Component[]
buttonTitleThe text displayed in a tooltip when the mouse pointer hovers over the button.String
buttonTypeSpecifies the type of button. Possible values: reset, submit, or button. This value defaults to button.Stringbutton
classA CSS style to be attached to the button. This style is added in addition to base styles output by the component.String
dataTargetSelectionNameCustom data attribute for target selectionString
disabledSpecifies whether this button should be displayed in a disabled state. Disabled buttons can't be clicked. Default value is "false".Booleanfalse
labelThe text displayed on the button. Corresponds to the value attribute of the rendered HTML input element.String
labelClassA CSS style to be attached to the label. This style is added in addition to base styles output by the component.String