Skip to main content

DateInput

Capture date input from user.

Submit feedback
github
import { DateInput } from '@uhg-abyss/mobile';

Important Note: The scrolling picker portion of this component is currently NOT accessible. The input box is accessible and can be used to enter a date or time with the keyboard. When a screen reader is active, the button to activate the picker will be hidden.

Usage

The DateInput component allows users to select a date or time from a picker. The picker will display a calendar for date selection and a time picker for time selection. The time picker is an internal component, but Calendar is a separate component that can be used independently.

Keyboard Entry

Users can enter the date or time with the native keyboard by pressing the input box. The date or time entered can be read from the value prop. Use the onSubmit prop to handle the action when the submit key is pressed. The date input will not accept an entry if it is not in the format of MM/DD/YYYY with leading zeros. The time input will not accept an entry if it is not in 12-hour hh:mm AM/PM format with leading zeros.

useState

The useState hook gets values from the component state. A date value is required and will be displayed in the input box and as the selected date or time on the picker.

Mode

Use the mode prop to define the type of picker. The default mode is set to "date"

Date

Time

Label

Use the label prop to display a label above the input menu.

Help Content

The helpContent prop is used to display a help icon in the top right of the container, which will display the provided content in a BottomSheet when pressed.

Required

Use the isRequired prop to display an asterisk next to the label.

Disabled

Set the isDisabled prop to true to disable the date picker.

Messages

Use the errorMessage and successMessage props to display a custom error or success message below the menu.

Excluded Dates

To exclude dates use the excludeDate prop. Set a function that receives date as an argument and returns true if date should be disabled. For example, to disable weekends, check if the day is 0 or 6.

Min/Max Date

Date

Use the minimumDate and maximumDate props to set the min and max dates in the Calendar dropdown.

Time

Use the minimumDate and maximumDate props to set the min and max times in the Time dropdown.

onInvalidEntry

Use the onInvalidEntry prop to handle the date validation. The function returns an object { value: Date, input: string, code: number, message: string } where value is the Date instance of the user's attempted entry, input is the string submitted by the user, code indicates a custom code that references a specific error and message describes the error. The explanation of code is noted below:

  • 0 - Indicates the input date is invalid.
  • 1 - Indicates the input is before the minimum date.
  • 2 - Indicates the input is after the minimum date.
  • 3 - Indicates the input is a disabled date.

DateInput Props

Prop NameTypeDefaultDescription
errorMessagestring-Sets the error message to be displayed below the date input field
excludeDateFunction-Callback fired to exclude dates from the calendar
helpButtonAccessibilityLabelstring-Sets the accessibility label for the help button
helpContentstring | ReactNode-When defined, displays a help icon that can be tapped to view the provided content in a modal screen
isDisabledbooleanfalseFlag to enable/disable the picker. If true, the picker will be disabled
isRequiredboolean-Visual indicator that a selection is required. If true, an asterisk will be displayed next to the label
labelstring-Label for date or time input field
maximumDateDate-Specifies the maximum selectable day by a user
minimumDateDate-Specifies the minimum selectable day by a user
modedate | timedateSets the mode of the date input to capture date or time entry
onChangefunction-Callback fired every time the value changes
onInvalidEntryfunction-Callback fired on date entry validation. Returns the entered date value
successMessagestring-Sets the success message to be displayed below the date input field
valueDate-Value of the date input

DateInput Classes

Class NameDescription
abyss-date-inputDate input element
abyss-date-input-bottom-sheetBottom sheet element
abyss-date-input-calendarCalendar
abyss-date-input-format-textFormat text element
abyss-date-input-headerHeader element
abyss-date-input-help-buttonHelp button
abyss-date-input-help-modalHelp modal
abyss-date-input-hint-textHint text element
abyss-date-input-iconThe date or time picker icon
abyss-date-input-icon-buttonThe date or time picker button
abyss-date-input-labelLabel element
abyss-date-input-messageMessage element
abyss-date-input-rootRoot element
abyss-date-input-submit-buttonSubmit button element
abyss-date-input-time-pickerTime picker
abyss-input-help-iconHelp icon element
abyss-input-help-modal-close-buttonHelp modal close button
abyss-input-help-modal-footerHelp modal footer
abyss-input-message-iconMessage icon
abyss-input-message-textMessage text

DateInput Translations

Translation KeyValue
helpHelp
closeClose
errorError
successSuccess
selectedSelected
DateInput.selectDateSelect Date
DateInput.selectTimeSelect Time
TimePicker.hoursHours
TimePicker.minutesMinutes
TimePicker.AMAM
TimePicker.PMPM
Calendar.prevMonthPrevious Month
Calendar.nextMonthNext Month
Calendar.yearYear
Calendar.todayToday
Calendar.inProgressIn Progress

DateInput Tokens

Token NameValue
input-header.color.text.label
#4B4D4F
input-header.color.text.hint
#4B4D4F
input-header.color.icon.help.rest
#196ECF
input-header.color.icon.help.active
#004BA0
input-message.color.text.error
#990000
input-message.color.text.success
#007000
input-message.color.icon.error
#990000
input-message.color.icon.success
#007000
input-field.color.surface.default
#FFFFFF
input-field.color.surface.disabled
#F3F3F3
input-field.color.text.input
#4B4D4F
input-field.color.border.rest.default
#4B4D4F
input-field.color.border.rest.error
#990000
input-field.color.border.rest.success
#007000
input-field.color.border.active.default
#196ECF
input-field.color.border.active.error
#990000
input-field.color.border.active.success
#007000
input-field.color.icon.utility.rest
#4B4D4F
input-field.color.icon.utility.disabled
#929496
input-field.color.icon.utility.active
#323334
input-field.border-radius.all.container
4
input-field.border-width.all.container.rest
1
input-field.border-width.all.container.active
3
input-header.sizing.all.icon.help
24
input-message.sizing.all.icon.leading
20
input-field.sizing.icon.all.utility
20
input-field.sizing.icon.all.picker
20
input-container.spacing.gap.vertical.container
8
input-header.spacing.gap.horizontal.container
12
input-header.spacing.gap.horizontal.label
4
input-header.spacing.gap.vertical.content
4
input-message.spacing.gap.horizontal.container
4
input-field.spacing.padding.all.field
12
input-field.spacing.gap.horizontal.field
12
input-field.spacing.gap.horizontal.input-indicator
2
input-field.spacing.gap.horizontal.prefix-input
2
input-field.box-shadow.container.active
  • Shadow Color: $core.color.brand.60
  • Shadow Offset:
    • Width: 0
    • Height: 0
  • Shadow Opacity: 1
  • Shadow Radius: 4
input-field.box-shadow.container.error
  • Shadow Color: $core.color.red.120
  • Shadow Offset:
    • Width: 0
    • Height: 0
  • Shadow Opacity: 1
  • Shadow Radius: 4
input-field.box-shadow.container.success
  • Shadow Color: $core.color.green.100
  • Shadow Offset:
    • Width: 0
    • Height: 0
  • Shadow Opacity: 1
  • Shadow Radius: 4
Table of Contents