Input Date (Deprecated)

ui:inputDate

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 date type.

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

Usage Overview (Deprecated) 

A ui:inputDate component represents a date input field, which is rendered as an HTML input tag of type text on desktop. To apply Lightning Design System styling, we recommend that you use lightning:input with type="date" instead of ui:inputDate.

Web apps running on mobiles and tablets use an input field of type date for all browsers except Internet Explorer. The value is displayed based on the locale of the browser, for example, MMM d, yyyy, which is returned by $Locale.dateFormat.

This is a basic set up of a date field with a date picker icon, which displays the field value Jan 30, 2014 based on the locale format. On desktop, the input tag is wrapped in a form tag.

1<ui:inputDate aura:id="dateField" label="Birthday" value="2014-01-30" displayDatePicker="true" />

Selecting A Date on Mobile Devices 

When viewed on a mobile or tablet, the ui:inputDate component uses the native date picker, and the format attribute is not supported in this case. We recommend using the value change handler to retrieve date value change on the input field. On iOS devices, selecting a date on the date picker triggers the change handler on the component but the value is bound only on the blur event. This example binds the date value to a value change handler.

1<aura:component>
2
3  <aura:attribute name="myDate" type="Date" />
4
5  <!-- Value change handler -->
6
7  <aura:handler name="change" value="{!v.myDate}" action="{!c.handleValueChange}" />
8
9  <ui:inputDate
10    aura:id="mySelectedDate"
11    label="Select a date"
12    displayDatePicker="true"
13    value="{!v.myDate}"
14  />
15
16</aura:component>

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
disabledSpecifies whether the component should be displayed in a disabled state. Default value is "false".Booleanfalse
displayDatePickerIndicates if an icon that triggers the date picker is displayed in the field. The default is false.Booleanfalse
errorsThe list of errors to be displayed.Object[]
formatThe java.text.SimpleDateFormat style format string.String
labelThe text of the label componentString
labelClassThe CSS class of the label componentString
langLocaleDeprecated. The language locale used to format date time. It only allows to use the value which is provided by Locale Value Provider, otherwise, it falls back to the value of $Locale.datetimeLocale. It will be removed in an upcoming release.String
requiredSpecifies whether the input is required. Default value is "false".Booleanfalse
requiredIndicatorClassThe CSS class of the required indicator componentString
updateOnUpdates the component's value binding if the updateOn attribute is set to the handled event. Default value is "change".Stringchange
valueThe input value of the date/time as an ISO string.String
valueThe value currently in the input field.String