Airframe GitHub Storybook
Component

ba-input-datepicker

Airframe

Active
Figma

Web Components

Active
Storybook GitHub

React

Active
Storybook GitHub

React Native

Planned
Design Code Accessibility QA
A

Label

Clearly identifies the purpose of the date field so users understand what date they are being asked to enter

B

Hint text

Optional supporting text that provides additional context or instructions to help users complete the field correctly

C

Input field

The native date input where the user enters or selects a date; its appearance and behaviour vary across browsers and devices

D

Calendar icon

A browser-native control that opens the datepicker popup; its presence and behaviour vary across browsers

This component is best used where users are choosing from a relatively compact range of dates, where a visual datepicker is helpful.

For situations with a wider range of possibilities, e.g. date of birth or credit card expiry, consider using the ba-date-input component instead.

As this component uses the browser's native date input, the UX of the input field and its datepicker vary across browsers and devices.

For example:

  • Chrome desktop has a button to open the datepicker, but doesn't open the datepicker automatically on click (like most other browsers)
  • Firefox desktop has a 'clear' button inside the input
  • Safari desktop has no button - clicking the input automatically opens the datepicker

Further reading:

As this component uses the browser's native date input, the format of the date value can vary based on browser and locale. Therefore you shouldn't refer to any particular format when instructing the user - e.g. Don't label it "Enter a date (dd/mm/yyyy)"

  • US and UK device locales (for example) display the day and month in different orders
  • Most browsers use a number format (01/01/2000) but iOS Safari shows the month in short word format (1 Jan 2000)

NB: The value accessed in code will be an empty string unless a valid date is entered, then value will always be in ISO format, regardless of the visual display format.

Further reading:

<ba-input-datepicker
  label="Outbound date"
  hint-text="Here's some help with this field"
  value="2023-10-01"
  name="date"
></ba-input-datepicker>
Property Attribute Description Type Default
hintText hint-text Hint text for the input string | undefined undefined
invalid invalid If true then the error will be displayed. boolean | undefined false
label(required) label Label for the input. string undefined
max max Optional max date value in yyyy-mm-dd format string | undefined this.getMaxDate()
min min Optional min date value in yyyy-mm-dd format string | undefined this.currentDate
name(required) name The name of the input string undefined
required required If the field is required boolean | undefined false
value value The value of the input. null | string | undefined ''
  • None
Slot Description Permitted elements
"error" Text to show in an error message <p>
"minError" Text to show in an minError message <p>
"maxError" Text to show in an maxError message <p>

ba-input-datepicker can be slotted into:

Event Description Type
baBlur Emitted when the input loses focus. CustomEvent<void>
baChange Emitted when the value has changed. CustomEvent<InputDatepickerChangeEventDetail>
baFocus Emitted when the input has focus. CustomEvent<void>
baSubmit Emitted when the input get submitted CustomEvent<void>
Basic usage
<ba-input-datepicker label="Outbound date" hint-text="Here's some help with this field"><p slot="error">Enter a valid date.</p></ba-input-datepicker>

The value will be an empty string unless a valid date is entered, then value will always be in ISO format, regardless of the visual display format.

The min and/or max attributes of the native date input can be set using the min and max attributes on the bagel component (in ISO format):

Setting min and max date values
<ba-input-datepicker hint-text="Here's some help with this field" min="2022-07-30" max="2023-07-30" label="Outbound date"></ba-input-datepicker>

On supporting browsers, these values restrict the range of dates that the user is able to select/input.

Prop Description Type Default
hintText Hint text for the input string | undefined undefined
invalid If true then the error will be displayed. boolean | undefined false
label (required) Label for the input. string undefined
max Optional max date value in yyyy-mm-dd format string | undefined this.getMaxDate()
min Optional min date value in yyyy-mm-dd format string | undefined this.currentDate
name (required) The name of the input string undefined
required If the field is required boolean | undefined false
value The value of the input. null | string | undefined ''
error Text to show in an error message <p>
minError Text to show in an minError message <p>
maxError Text to show in an maxError message <p>

None

BaInputDatepicker can be slotted into:

Events Description
onBaBlur Called when the input loses focus.
onBaChange Called when the value has changed.
onBaFocus Called when the input has focus.
onBaSubmit Called when the input get submitted
Basic usage
<BaInputDatepicker
  label="Outbound date"
  hintText="Here's some help with this field"
  error="Enter a valid date."
/>

The value will be an empty string unless a valid date is entered, then value will always be in ISO format, regardless of the visual display format.

The min and/or max attributes of the native date input can be set using the min and max attributes on the bagel component (in ISO format):

Setting min and max date values
<BaInputDatepicker
  label="Outbound date"
  hintText="Here's some help with this field"
  min="2022-07-30"
  max="2023-07-30"
/>

On supporting browsers, these values restrict the range of dates that the user is able to select/input.

React Native documentation coming soon.

Always use the label attribute to give a meaningful label to the field.

Further reading:

Disabled form elements are not supported in BAgel because they create accessibility challenges, such as preventing keyboard navigation, confusing screen reader users, and reducing visual clarity for those with impairments

Further reading:

State: Previous element in DOM has focus

⇥ Tab

The date input gets focus

State: Date input has focus

⇥ Tab

Next tabbable element gets focus

Use this checklist to confirm the component has been configured and used correctly.

  • Use ba-input-datepicker for compact date ranges where a visual datepicker is helpful, such as selecting a travel date
  • For wider date ranges such as date of birth or credit card expiry, use ba-date-input instead
  • Do not reference a specific date format in the label or hint text, as the display format varies by browser and locale
  • The component renders consistently across supported browsers, accounting for native differences
  • The input has a visible and descriptive label
  • Hint text is programmatically associated with the input
  • Error messages are visible and associated with the input
  • The disabled state is communicated to assistive technology
  • Focus indicator has not been obscured on all sides of the component

These checks are handled by the component and do not need to be repeated each time it is used.

  • ba-input-datepicker is operable using assistive technology
  • Has a visible focus indicator on all sides of the component
  • Colour contrast for all states in all BAgel themes
  • High contrast mode adjustments
Designing Developing Components BAgel helper QA process britishairways.com Careers Cookie policy