Airframe GitHub Storybook
Component

ba-input-number

A form field for entering numbers

Airframe

Not Planned

Web Components

Active
Storybook GitHub

React

Active
Storybook GitHub

React Native

Planned

Help picking the right number input

This component should only be used for entering numbers such as prices, quantities, IDs, or other numeric data that could be multiple digits (e.g., 100, 2500, 42.75).

Design Code Accessibility QA
A

Label

A short, descriptive text that identifies the purpose of the input field

B

Hint text (optional)

Additional guidance below the label to help users complete the field correctly

C

Input field

The numeric entry area where users type their response

<ba-input-number label="Label text" name="numberInput" hint-text="Custom hint text" required></ba-input-number>
Property Attribute Description Type Default
autocomplete autocomplete The autocomplete setting string | undefined 'on'
hintText hint-text Hint text to show above the input string | undefined undefined
inputWidth input-width The width of the input in characters string | undefined undefined
invalid invalid Whether the input is invalid boolean | undefined false
label(required) label A label for the input string undefined
maxLength max-length Max amount of characters allowed in validation string | undefined undefined
minLength min-length Min amount of characters allowed in validation string | undefined undefined
name name The name of the input string | undefined undefined
required required Whether the input is required boolean | undefined false
value value The value of the input string | undefined ''
  • None
Slot Description Permitted elements
"error" Element will be rendered in the error slot <p>
"error-not-a-number" Element will be rendered in the error-not-a-number slot <p>
"error-required" Element will be rendered in the error-required slot <p>
"error-min-length" Element will be rendered in the error-min-length slot <p>
"error-max-length" Element will be rendered in the error-max-length slot <p>

ba-input-number can be slotted into:

Event Description Type
baBlur Emitted when the input loses focus CustomEvent<void>
baFocus Emitted when the input has focus CustomEvent<void>
baOnInput Emitted when a keyboard input occurred CustomEvent<KeyboardEvent>
baSubmit Emitted when the user submits the form from within the component CustomEvent<void>
Method Description
isValid() => Promise<boolean> Triggers required validation and resolves with validity state
reset() => Promise<void> Resets the input back to its initial value

Most scenarios will only require the label attribute and a name.

A simple number input
<ba-input-number label="Label text" name="number" required></ba-input-number>

It is sometimes useful to add hint text.

A number input that has hint text
<ba-input-number label="Label text" name="number" hint-text="Custom hint text" required></ba-input-number>

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

We do provide error messages with translations for:

  • required
  • not a number
A number input that has custom error messages and hint text
<ba-input-number label="Label text" name="number" hint-text="Custom hint text" required>
  <p slot="error">
    We need to know this. <a href="#">Why we need to know</a>
  </p>
</ba-input-number>
Prop Description Type Default
autocomplete The autocomplete setting string | undefined 'on'
hintText Hint text to show above the input string | undefined undefined
inputWidth The width of the input in characters string | undefined undefined
invalid Whether the input is invalid boolean | undefined false
label (required) A label for the input string undefined
maxLength Max amount of characters allowed in validation string | undefined undefined
minLength Min amount of characters allowed in validation string | undefined undefined
name The name of the input string | undefined undefined
required Whether the input is required boolean | undefined false
value The value of the input string | undefined ''
error Element will be rendered in the error slot <p>
errorNotANumber Element will be rendered in the error-not-a-number slot <p>
errorRequired Element will be rendered in the error-required slot <p>
errorMinLength Element will be rendered in the error-min-length slot <p>
errorMaxLength Element will be rendered in the error-max-length slot <p>

None

BaInputNumber can be slotted into:

Event handler Description
onBaBlur Emitted when the input loses focus
onBaFocus Emitted when the input has focus
onBaInput Emitted when a keyboard input occurred
onBaSubmit Emitted when the user submits the form from within the component
Method Description
isValid() => Promise<boolean> Triggers required validation and resolves with validity state
reset() => Promise<void> Resets the input back to its initial value and validity

Most scenarios will only require the label attribute and a name.

A simple number input
<BaInputNumber label="Label text" name="number" required />

It is sometimes useful to add hint text.

A number input that has hint text
<BaInputNumber label="Label text" name="number" hintText="Custom hint text" required />

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

We do provide error messages with translations for:

  • required
  • not a number
A number input that has custom error messages and hint text
<BaInputNumber
  label="Label text"
  name="number"
  hintText="Custom hint text"
  required
  error="We need to know this"
/>

React Native documentation coming soon.

When an input uses type="number" it's role becomes spinbutton. This presents the risk of users accidentally incrementing a number when they're trying to do something else. It also prevents users from inputting non numerical characters with no feedback as to why. To resolve this we use a combination of inputmode="numeric" and a pattern="[0-9]*". This allows us to validate the input correctly and show relevant error messages to the user.

More info can be found below:

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:

Placeholders on inputs are not supported in BAgel because they create accessibility challenges, such as failing to provide persistent labels for screen readers, reducing color contrast for users with visual impairments, and causing confusion for those with cognitive difficulties.

If you would like to add a infomations to help the user fill the input, you can use the hint-text attribute.

Further reading:

State: Previous element in DOM has focus

⇥ Tab

Moves focus to the ba-input-number input field

State: ba-input-number input has focus

⇥ Tab

Moves focus to the next focusable element

⇧ Shift + ⇥ Tab

Moves focus to the previous focusable element

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

  • ba-input-number is only used for entering numbers such as prices, quantities, IDs, or other numeric data that could be multiple digits
  • ba-input-text is used instead when users need to enter numbers and text together
  • ba-input-phone-number is used instead for phone numbers
  • ba-input-stepper is used instead for very short or single-digit numeric entries where incrementing/decrementing is common
  • A concise and descriptive label has been provided
  • Hint text is used when the expected format or constraints may not be obvious to the user
  • Required fields are marked with the required attribute
  • A meaningful label is provided via the label attribute
  • Hint text is used in preference to placeholder text, which is not supported
  • Error messages are descriptive and explain how to resolve the validation failure
  • The disabled state is not used — ba-input-number does not support disabled inputs

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

  • The input does not use type="number", avoiding the spinbutton role and its risk of accidental value changes
  • The field is keyboard operable and receives a visible focus indicator
  • Colour contrast meets WCAG AA for text and border in all states (default, focus, error)
  • The component renders correctly in Windows High Contrast Mode
  • Animation and transitions respect the prefers-reduced-motion media query
Designing Developing Components BAgel helper Web QA React Native QA britishairways.com Careers Cookie policy