Airframe GitHub Storybook
Component

ba-input-date

A form field for entering dates

Airframe

Active
Figma

Web Components

Active
Storybook GitHub

React

Planned

React Native

Planned
Design Code Accessibility QA
A

Date label

A short, descriptive text that identifies the group of inputs and the date the user is being asked to enter

B

Field labels

The DD, MM and YYYY labels above each input that indicate the expected format for the day, month and year

C

Input fields

The separate day, month and year fields where users enter each portion of the date

This component can be used for entering a range of different date types such as dates of births, credit/debit expiries and other dates.

<ba-input-date
  legend="Date of Birth"
  name="dateOfBirth"
  required
></ba-input-date>
Property Attribute Description Type Default
autocompleteDay autocomplete-day Indicates whether the value of the control can be automatically completed by the browser.
Valid values are 'on' or 'off' but Chrome ignores 'off' so we use another value to disable autocomplete.
string | undefined 'null'
autocompleteMonth autocomplete-month Indicates whether the value of the control can be automatically completed by the browser.
Valid values are 'on' or 'off' but Chrome ignores 'off' so we use another value to disable autocomplete.
string | undefined 'null'
autocompleteYear autocomplete-year Indicates whether the value of the control can be automatically completed by the browser.
Valid values are 'on' or 'off' but Chrome ignores 'off' so we use another value to disable autocomplete.
string | undefined 'null'
dayLabel day-label Label text for the day field string | undefined undefined
ignoreDay ignore-day If true then the day input will not be displayed. boolean | undefined false
inputId input-id ID for the host and also used in IDs for the child inputs. Randomised value used as fallback but an id value should always be given in the application. string | undefined `id${Math.round( Math.random() * 1e10 )}`
invalid invalid If true then the error will be displayed. boolean | undefined false
legend(required) legend Text for the legend string undefined
monthLabel month-label Label text for the month field string | undefined undefined
name(required) name The name of the input string undefined
required required If the input is required boolean | undefined false
value value The value of the input. null | string | undefined ''
yearDigits year-digits The number of digits for the year field. number | undefined 4
yearLabel year-label Label text for the year field string | undefined undefined
  • None
Slot Description Permitted elements
"error" Text to show in an error message <p>

ba-input-date can be slotted into:

Event Description Type
baBlur Emitted when the input loses focus. CustomEvent<void>
baChange Emitted when the value has changed. CustomEvent<InputDateChangeEventDetail>
baFocus Emitted when the input has focus. CustomEvent<void>

isValid() => Promise<boolean>

An exposed method for triggering the inputs required validation

reset() => Promise<void>

Resets the input back to its initial value

Returns

Type: Promise<void>

Most scenarios will only require the legend attribute and the required attribute.

A simple date input
<ba-input-date
  legend="Date of Birth"
  required
></ba-input-date>

Use year-digits and ignore-day together with the relevant autocomplete settings for card expiry details.

A date input for card expiry details
<ba-input-date
    legend="Card Expiry"
    year-digits="2"
    ignore-day
    autocomplete-month="cc-exp-month"
    autocomplete-year="cc-exp-year"
    required
  ></ba-input-date>

It is sometimes useful to add custom validation messages. For example you may wish to:

  • Add translations
  • Provide more detail and/or contextual advice
  • Add links to further information on the error

BAgel provides error messages with translations for:

  • required
  • numeric
  • 30 day month
  • leap years
  • february
A date input that has custom error message
<ba-input-date
    legend="Date of Birth"
    required
  >
  <p slot="error">We need to know this. <a href="#">Why we need to know</a>
  </p>
  </ba-input-date>

React documentation coming soon.

React Native documentation coming soon.

The legend text helps users of assistive technologies understand that this component is a group of related form fields.

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:

The autocomplete attribute can be set for each of the inputs (day, month and year). This helps the user by allowing the browser to suggest saved details.

Some screen readers (NVDA) may interpret abbreviations like "MM" using their own pronunciation rules and read it as "millimetres." This behaviour comes from the assistive technology rather than the component, and forcing custom pronunciation is not recommended. Providing clear contextual labels (for example, including "month" alongside "MM") helps ensure the field remains understandable across screen readers.

Further reading:

State: Previous element in DOM has focus

⇥ Tab

Moves focus to the day input

State: Day input has focus

⇥ Tab

Moves focus to the month input

⇧ Shift + ⇥ Tab

Moves focus to the previous focusable element

State: Month input has focus

⇥ Tab

Moves focus to the year input

⇧ Shift + ⇥ Tab

Moves focus back to the day input

State: Year input has focus

⇥ Tab

Moves focus to the next focusable element

⇧ Shift + ⇥ Tab

Moves focus back to the month input

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

  • ba-input-date is used for entering full dates such as dates of birth, card expiry, and other dates
  • year-digits and ignore-day are used to adapt the component for shortened dates such as card expiry (MM/YY)
  • A concise and descriptive legend has been provided for the group of inputs
  • Required fields are marked with the required attribute
  • The correct autocomplete settings are applied to the day, month, and year inputs
  • A meaningful legend is provided to describe the group of day, month, and year inputs
  • The correct autocomplete attribute is set for each input so the browser can suggest saved details
  • Error messages are descriptive and explain how to resolve the validation failure
  • The inputs have not been disabled
  • The 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.

  • Contextual labels are provided so abbreviations such as "MM" remain understandable across screen readers
  • ba-input-date is operable using assistive technology
  • The field is keyboard operable and receives a visible focus indicator
  • Colour contrast for all states in all BAgel themes
  • High contrast mode adjustments
Designing Developing Components BAgel helper Web QA React Native QA britishairways.com Careers Cookie policy