Airframe GitHub Storybook
Component

ba-radio-group

A container component for grouping multiple ba-radio and ba-radio-card components into a single form field, providing users with a clear choice of options

Airframe

Active
Figma

Web Components

Active
Storybook GitHub

React

Active
Storybook GitHub

React Native

Planned
Design Code Accessibility QA
A

Legend

Clearly labels the group of options so users understand what they are choosing between

B

Hint text (optional)

Provides supporting context or instructions to help users make a choice

C

Options

The list of ba-radio or ba-radio-card components that make up the group, only one of which can be selected

Positioning ba-radio components after ba-radio-card components helps maintain a clear visual hierarchy, guiding users from options with more detailed descriptions to simpler choices. This layout improves usability and ensures a logical flow in the selection process.

<ba-radio-group
    legend="Pick an option"
    hint-text="Some hint text to help select the right option"
    name="name"
  >
  <ba-radio-card label="Flight 1" value="flight1">
    <ba-content>
      <p>Flight 1 details</p>
    </ba-content>
  </ba-radio-card>
  <ba-radio-card label="Flight 2" value="flight2">
    <ba-content>
      <p>Flight 2 details</p>
    </ba-content>
  </ba-radio-card>
  <ba-radio label="Flight 3" value="flight3"></ba-radio>
  <ba-radio label="Flight 4" value="flight4"></ba-radio>
</ba-radio-group>
Property Attribute Description Type Default
hintText hint-text Text to display between the legend and the radios string | undefined ''
invalid invalid Set the radio group to invalid state boolean | undefined false
layout1024vw layout-1024vw Controls the direction the radio buttons go. "grid-2" | "grid-3" | "horizontal" | "vertical" | undefined 'vertical'
legend(required) legend Sets the radio group legend which will fill the fieldset legend string undefined
name(required) name Input name to be applied to all radio children string undefined
required required Set to trigger the is required validation boolean | undefined false
value value the value of the radio group. string | undefined ''
visuallyHiddenLegend visually-hidden-legend Sets the radio group visually hidden text which can be read out by screen readers
to give added context on what the radio buttons will do
string | undefined undefined
  • None
Slot Description Permitted elements
Unnamed slot ba-radio components will be rendered here <ba‑radio>, <ba‑radio‑card>
"error" Element will be rendered in the error slot <p>

ba-radio-group can be slotted into:

Event Description Type
baChange Emitted when the value gets updated. CustomEvent<RadioGroupChangeEventDetail>
Method Description Type
isValid() => Promise<boolean> An exposed method for triggering the inputs required validation. Promise<boolean>
reset() => Promise<void> An exposed method for resetting the radio group to its default state. Promise<void>

In most scenarios, you will use ba-radio-group to group multiple ba-radio or ba-radio-card components together. This allows users to select a single option from a list of choices.

A list of ba-radio's used to select a flight
<ba-radio-group
    legend="Pick an option"
    name="groupName"
    required
  >
  <ba-radio label="Flight 1" value="flight1"></ba-radio>
  <ba-radio label="Flight 2" value="flight2"></ba-radio>
  <ba-radio label="Flight 3" value="flight3"></ba-radio>

  <p slot="error">Custom required error message</p>
</ba-radio-group>
A list of ba-radio-cards used to select a flight with more details
<ba-radio-group
  legend="Pick an option"
  name="groupName"
>
  <ba-radio-card label="Flight 1" value="flight1">
    <ba-content>
      <p>Flight 1 description</p>
    </ba-content>
  </ba-radio-card>
  <ba-radio-card label="Flight 2" value="flight2">
    <ba-content>
      <p>Flight 2 description</p>
    </ba-content>
  </ba-radio-card>
  <ba-radio-card label="Flight 3" value="flight3">
    <ba-content>
      <p>Flight 3 description</p>
    </ba-content>
  </ba-radio-card>

</ba-radio-group>

In some cases, you may want to mix ba-radio and ba-radio-card components within the same ba-radio-group. This can be useful when you want to provide users with a mix of simple and detailed options.

A list of ba-radio-cards used to select a flight with more details
<ba-radio-group
  legend="Pick an option"
  name="groupName"
>
  <ba-radio-card label="Flight 1" value="flight1">
    <ba-content>
      <p>Flight 1 description</p>
    </ba-content>
  </ba-radio-card>
  <ba-radio-card label="Flight 2" value="flight2">
    <ba-content>
      <p>Flight 2 description</p>
    </ba-content>
  </ba-radio-card>
  <ba-radio label="Flight 3" value="flight3"></ba-radio>
  <ba-radio label="Flight 4" value="flight4"></ba-radio>

</ba-radio-group>

An icon can be shown between the input and the label.

Showing icons within ba-radio-card
<ba-radio-group
  legend="Pick an option"
  name="groupName"
>
  <ba-radio-card label="Flight 1" value="flight1" icon="arriving">
    <ba-content>
      <p>Flight 1 description</p>
    </ba-content>
  </ba-radio-card>
</ba-radio-group>

A common pattern in forms is to change the UI depending on the selections users make or the data users enter. Providing some hidden text alongside the form element informs the user what will happen in response to their action.

Further reading:

A search form dynamically changes the inputs shown to the user depending on the radio button selection. Hidden text lets the screen reader user know this change will happen when they update their selection
<ba-radio-group legend="Search by airport or flight number" visually-hidden-legend="Changing this value will update the fields available in this form">

  <ba-radio>
    <span slot="label">Airport</span>
  </ba-radio>

  <ba-radio>
    <span slot="label">Flight number</span>
  </ba-radio>

  <div aria-live="polite">
    <!-- Dynamically added/removed form inputs -->
  </div>
</ba-radio-group>

BAgel provides a translated required error message, however it is sometimes useful to add custom validation messages. For example you may wish to:

  • Add additional translations
  • Provide more detail and/or contextual advice
  • Add links to further information on the error
A radio group with a custom error message
<ba-radio-group legend="Search by airport or flight number" required>
  <!-- Place ba-radio's and ba-radio-card's here -->

  <p slot="error">Custom error message</p>
</ba-radio-group>
Prop Description Type Default
hintText Text to display between the legend and the radios string | undefined ''
invalid Set the radio group to invalid state boolean | undefined false
layout1024vw Controls the direction the radio buttons go. "grid-2" | "grid-3" | "horizontal" | "vertical" | undefined 'vertical'
legend (required) Sets the radio group legend which will fill the fieldset legend string undefined
name (required) Input name to be applied to all radio children string undefined
required Set to trigger the is required validation boolean | undefined false
value the value of the radio group. string | undefined ''
visuallyHiddenLegend Sets the radio group visually hidden text which can be read out by screen readers
to give added context on what the radio buttons will do
string | undefined undefined
children ba-radio components will be rendered here <ba‑radio>, <ba‑radio‑card>
error Element will be rendered in the error slot <p>
Method Description Type
isValid() => Promise<boolean> An exposed method for triggering the inputs required validation. Promise<boolean>
reset() => Promise<void> An exposed method for resetting the radio group to its default state. Promise<void>

None

BaRadioGroup can be slotted into:

In most scenarios, you will use BaRadioGroup to group multiple BaRadio components together. This allows users to select a single option from a list of choices.

A list of BaRadio's used to select a flight
<BaRadioGroup
    legend="Pick an option"
    name="groupName"
    required
    error="Custom required error message">
<BaRadio label="Flight 1" value="flight1" />
<BaRadio label="Flight 2" value="flight2" />
<BaRadio label="Flight 3" value="flight3" />
</BaRadioGroup>

A common pattern in forms is to change the UI depending on the selections users make or the data users enter. Providing some hidden text alongside the form element informs the user what will happen in response to their action.

Further reading:

A search form dynamically changes the inputs shown to the user depending on the radio button selection. Hidden text lets the screen reader user know this change will happen when they update their selection
<BaRadioGroup legend="Search by airport or flight number" visuallyHiddenLegend="Changing this value will update the fields available in this form">

    <BaRadio label="Airport" />

    <BaRadio label="Flight number" />

    <div aria-live="polite">
      <!-- Dynamically added/removed form inputs -->
    </div>
  </BaRadioGroup>

BAgel provides a translated required error message, however it is sometimes useful to add custom validation messages. For example you may wish to:

  • Add additional translations
  • Provide more detail and/or contextual advice
  • Add links to further information on the error
A radio group with a custom error message
<BaRadioGroup legend="Search by airport or flight number" required error="Custom error message">
    <!-- Place BaRadio's here -->
  </BaRadioGroup>

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:

This attribute gives screen readers more information to read out to the user. A common pattern in forms is to change the UI depending on the selections users make or the data users enter. Providing some hidden text alongside the form element informs the user what will happen in response to their action.

State: Previous element in DOM has focus

⇥ Tab

Focus moves to the checked radio or radio card in the group, or the first radio or radio card if none are checked

State: A radio or radio card in the group has focus

↑ Arrow Up

Moves focus to and selects the previous radio or radio card in the group

↓ Arrow Down

Moves focus to and selects the next radio or radio card in the group

← Arrow Left

Moves focus to and selects the previous radio or radio card in the group

→ Arrow Right

Moves focus to and selects the next radio or radio card in the group

⇥ Tab

Next tabbable element outside the group gets focus, including any nested clickable elements or the error slot

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

  • ba-radio-group is used when a single option must be selected from a list of choices
  • ba-radio components are placed after ba-radio-card components when used in the same ba-radio-group
  • Legend text is clear and concise, and describes the choice being made
  • Use visually-hidden-legend to prewarn users of UI changes that happen when the value changes
  • A visible legend is always provided
  • Disabled state is not used; disabled form elements are not supported in BAgel
  • Group is operable with keyboard using tab to focus and arrow keys to change selection
  • 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-radio-group 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
  • Animations respect users' reduced motion settings
  • High contrast mode adjustments
Designing Developing Components BAgel helper QA process britishairways.com Careers Cookie policy