Input Checkbox (Deprecated)

ui:inputCheckbox

Deprecated as of API version 47.0. We recommend migrating to Lightning Web Components and using the lightning-input 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-input with checkbox, toggle, or checkbox-button type. For checkbox groups, use lightning-checkbox-group.

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

Usage Overview (Deprecated) 

A ui:inputCheckbox component represents a checkbox whose state is controlled by the value and disabled attributes. It’s rendered as an HTML input tag of type checkbox. To render the output from a ui:inputCheckbox component, use the ui:outputCheckbox component.

This is a basic set up of a checkbox.

1<ui:inputCheckbox label="Reimbursed?" />

This example results in the following HTML.

1<div class="uiInput uiInputCheckbox uiInput--default uiInput--checkbox">
2  <label class="uiLabel-left form-element__label uiLabel">
3    <span>Reimbursed?</span>
4  </label>
5  <input type="checkbox" />
6</div>

The value attribute controls the state of a checkbox, and events such as click and change determine its behavior. This example updates the checkbox CSS class on a click event.

1<!-- Component Markup -->
2
3<ui:inputCheckbox label="Color me" click="{!c.update}" />
1/** Client-Side Controller **/
2update : function (cmp, event) {
3  $A.util.toggleClass(event.getSource(), "red");
4}

To create forms for Salesforce objects without using Apex controllers, use lightning:inputField with lightning:recordEditForm, or use lightning:recordForm. To create an input field for different data types, use lightning:input.

Note

Attributes 

NameDescriptionTypeDefaultRequired
bodyThe body of the component. In markup, this is everything in the body of the tag.Aura.Component[]
classA CSS style to be attached to the component. This style is added in addition to base styles output by the component.String
classA CSS style to be attached to the component. This style is added in addition to base styles output by the component.String
disabledSpecifies whether the component should be displayed in a disabled state. Default value is "false".Booleanfalse
disabledSpecifies whether the component should be displayed in a disabled state. Default value is "false".Booleanfalse
errorsThe list of errors to be displayed.Object[]
labelThe text displayed on the component.String
labelThe text of the label componentString
labelClassThe CSS class of the label componentString
nameThe name of the component.String
requiredSpecifies whether the input is required. Default value is "false".Booleanfalse
requiredIndicatorClassThe CSS class of the required indicator componentString
textThe input value attribute.String
updateOnUpdates the component's value binding if the updateOn attribute is set to the handled event. Default value is "change".Stringchange
valueIndicates whether the status of the option is selected. Default value is “false”.Booleanfalse
valueThe value currently in the input field.String