Airframe GitHub Storybook
Component

ba-flex

This component provides a flex layout for items that should be laid out side by side, or that can wrap onto the next line.

Airframe

Not Planned

Web Components

Active
Storybook GitHub

React

Active
Storybook GitHub

React Native

Beta
GitHub
Design Code Accessibility QA

Picking between ba-flex and ba-grid

Use ba-flex for:

  • Simple layouts where items can be sat side by side
  • Layouts with dynamically sized items where set columns would cause layout shifts

Use ba-grid for:

  • Complex layouts
  • Layouts where multiple rows are required
A

Parent ba-flex

The outer flex container that arranges child elements in rows and controls wrapping behavior

B

Flex items

Child elements placed inside ba-flex that flow in source order and wrap to new rows when needed

C

Column gutters

Horizontal spacing between items in each row, configurable at viewport breakpoints

D

Row gutters

Vertical spacing between wrapped rows, configurable at viewport breakpoints

If ba-image is being used, a width is required to be set on ba-image to make it show within the flex grid. This is because the way the aspect ratio gets set within ba-image results in the main component not having a width.

<ba-flex>
  <div class="placeholder"></div>
  <div class="placeholder"></div>
  <div class="placeholder"></div>
  <div class="placeholder"></div>
</ba-flex>
Property Attribute Description Type Default
alignContent align-content Which direction to align the content within the flex container "right" | undefined undefined
columnGutter1024vw column-gutter-1024vw Set's the gutter between columns of the grid at 1024px and wider "16" | "24" | "32" | "40" | "64" | "8" | "96" | undefined undefined
columnGutter320vw column-gutter-320vw Set's the gutter between columns of the grid at 320px and wider "16" | "24" | "32" | "8" | undefined '8'
columnGutter480vw column-gutter-480vw Set's the gutter between columns of the grid at 480px and wider "16" | "24" | "32" | "8" | undefined undefined
columnGutter640vw column-gutter-640vw Set's the gutter between columns of the grid at 640px and wider "16" | "24" | "32" | "8" | undefined undefined
columnGutter800vw column-gutter-800vw Set's the gutter between columns of the grid at 800px and wider "16" | "24" | "32" | "40" | "64" | "8" | undefined undefined
rowGutter1024vw row-gutter-1024vw Set's the gutter between rows of the grid at 1024px and wider "16" | "24" | "32" | "40" | "8" | undefined undefined
rowGutter320vw row-gutter-320vw Set's the gutter between rows of the grid at 320px and wider "16" | "24" | "8" | undefined '8'
rowGutter480vw row-gutter-480vw Set's the gutter between rows of the grid at 480px and wider "16" | "24" | "8" | undefined undefined
rowGutter640vw row-gutter-640vw Set's the gutter between rows of the grid at 640px and wider "16" | "24" | "8" | undefined undefined
rowGutter800vw row-gutter-800vw Set's the gutter between rows of the grid at 800px and wider "16" | "24" | "32" | "40" | "8" | undefined undefined
  • list
  • listitem
Slot Description Permitted elements
Unnamed slot Elements will render in the body of the component <a>, <article>, <aside>, <ba‑accordion>, <ba‑button>, <ba‑card>, <ba‑card‑segmented>, <ba‑chart‑price>, <ba‑checkbox>, <ba‑checkbox‑list>, <ba‑content>, <ba‑copy‑to‑clipboard>, <ba‑details>, <ba‑entry>, <ba‑flex>, <ba‑flight‑number>, <ba‑form>, <ba‑form‑group>, <ba‑form‑group‑dropdown>, <ba‑header‑list>, <ba‑icon>, <ba‑image>, <ba‑inline‑list>, <ba‑input>, <ba‑input‑date>, <ba‑input‑datepicker>, <ba‑input‑email>, <ba‑input‑number>, <ba‑input‑password>, <ba‑input‑phone‑number>, <ba‑input‑secure‑field>, <ba‑input‑stepper>, <ba‑input‑text>, <ba‑input‑textarea>, <ba‑input‑typeahead>, <ba‑input‑upload>, <ba‑link>, <ba‑link‑back>, <ba‑link‑entry>, <ba‑link‑price>, <ba‑link‑tile>, <ba‑loading‑skeleton>, <ba‑logo>, <ba‑media‑object>, <ba‑message>, <ba‑radio‑group>, <ba‑select>, <ba‑star‑rating>, <ba‑tab‑chip‑group>, <ba‑tag>, <div>, <fieldset>, <form>, <nav>, <section>, <svg>, <ul>

ba-flex can be slotted into:

All the column and row attributes on this component contain a number followed by vw which defines the viewport width (in pixels) that the value will be applied. The value provided will then persist at each wider viewport until another attribute has been set.

For example setting column-gutter-480vw and column-gutter-640vw attributes will:

  • apply the default value for column gutters between viewport widths up to 479px
  • apply the value set in column-gutter-480vw between viewport widths of 480px and 639px
  • apply the value set in column-gutter-640vw at all viewport widths larger than 640px

If the amount of child items is larger than the width of ba-flex, they will get wrapped onto the next line automatically. Just the same as a normal Flexbox container would with the flex-wrap: wrap; property.

Aligning a group of items in a row is as simple as wrapping them with the ba-flex component.

Group of aligned items
<ba-flex>
  <div></div>
  <div></div>
  <div></div>
</ba-flex>
Group of items aligned to the right
<ba-flex align-content="right">
  <div></div>
  <div></div>
  <div></div>
</ba-flex>

The spacing (gutters) between the rows can be edited by passing a value to the row-gutter-<viewport>vw attributes. Row gutters by default will match the gutters between columns at each viewport. If a row gutter has been set then that value will persist across all larger viewports ignoring the default row gutter values.

Setting the row gutter to the default (8px) at the 320px viewport and 16px at the 480px viewport and wider
<ba-flex row-gutter-480vw="16"> ... </ba-flex>
Setting the row gutter to defaults at 320px & 480px viewports (8px and 16px) and 32px at the 640px viewport and wider
<ba-flex row-gutter-640vw="32"> ... </ba-flex>
Setting the row gutter to 32px at the 480px viewport and then reducing to 24px at the 800px viewport and wider
<ba-flex row-gutter-480vw="32" row-gutter-800vw="24"> ... </ba-flex>

The spacing (gutters) between the columns can be edited by passing a value to the column-gutter-<viewport>vw attributes. Column gutters by default will match the gutter between rows at each viewport. If a column gutter has been set then that value will persist across all larger viewports ignoring the default row gap values.

Setting the column gutter to the default (8px) at the 320px viewport and 16px at the 480px viewport and wider
<ba-flex column-gutter-480vw="16"> ... </ba-flex>
Setting the column gutter to defaults at 320px & 480px viewports (8px and 16px) and 32px at the 640px viewport and wider
<ba-flex column-gutter-640vw="32"> ... </ba-flex>
Setting the column gutter to 32px at the 480px viewport and then reducing to 24px at the 800px viewport and wider
<ba-flex column-gutter-480vw="32" column-gutter-800vw="24"> ... </ba-flex>
Prop Description Type Default
alignContent Which direction to align the content within the flex container "right" | undefined undefined
columnGutter1024vw Set's the gutter between columns of the grid at 1024px and wider "16" | "24" | "32" | "40" | "64" | "8" | "96" | undefined undefined
columnGutter320vw Set's the gutter between columns of the grid at 320px and wider "16" | "24" | "32" | "8" | undefined '8'
columnGutter480vw Set's the gutter between columns of the grid at 480px and wider "16" | "24" | "32" | "8" | undefined undefined
columnGutter640vw Set's the gutter between columns of the grid at 640px and wider "16" | "24" | "32" | "8" | undefined undefined
columnGutter800vw Set's the gutter between columns of the grid at 800px and wider "16" | "24" | "32" | "40" | "64" | "8" | undefined undefined
rowGutter1024vw Set's the gutter between rows of the grid at 1024px and wider "16" | "24" | "32" | "40" | "8" | undefined undefined
rowGutter320vw Set's the gutter between rows of the grid at 320px and wider "16" | "24" | "8" | undefined '8'
rowGutter480vw Set's the gutter between rows of the grid at 480px and wider "16" | "24" | "8" | undefined undefined
rowGutter640vw Set's the gutter between rows of the grid at 640px and wider "16" | "24" | "8" | undefined undefined
rowGutter800vw Set's the gutter between rows of the grid at 800px and wider "16" | "24" | "32" | "40" | "8" | undefined undefined
children Elements will render in the body of the component <a>, <article>, <aside>, <ba‑accordion>, <ba‑button>, <ba‑card>, <ba‑card‑segmented>, <ba‑chart‑price>, <ba‑checkbox>, <ba‑checkbox‑list>, <ba‑content>, <ba‑copy‑to‑clipboard>, <ba‑details>, <ba‑entry>, <ba‑flex>, <ba‑flight‑number>, <ba‑form>, <ba‑form‑group>, <ba‑form‑group‑dropdown>, <ba‑header‑list>, <ba‑icon>, <ba‑image>, <ba‑inline‑list>, <ba‑input>, <ba‑input‑date>, <ba‑input‑datepicker>, <ba‑input‑email>, <ba‑input‑number>, <ba‑input‑password>, <ba‑input‑phone‑number>, <ba‑input‑secure‑field>, <ba‑input‑stepper>, <ba‑input‑text>, <ba‑input‑textarea>, <ba‑input‑typeahead>, <ba‑input‑upload>, <ba‑link>, <ba‑link‑back>, <ba‑link‑entry>, <ba‑link‑price>, <ba‑link‑tile>, <ba‑loading‑skeleton>, <ba‑logo>, <ba‑media‑object>, <ba‑message>, <ba‑radio‑group>, <ba‑select>, <ba‑star‑rating>, <ba‑tab‑chip‑group>, <ba‑tag>, <div>, <fieldset>, <form>, <nav>, <section>, <svg>, <ul>

None

BaFlex can be slotted into:

All the column and row props on this component contain a number followed by vw which defines the viewport width (in pixels) that the value will be applied. The value provided will then persist at each wider viewport until another prop has been set.

For example setting columnGutter480vw and columnGutter640vw props will:

  • apply the default value for column gutters between viewport widths up to 479px
  • apply the value set in columnGutter480vw between viewport widths of 480px and 639px
  • apply the value set in columnGutter640vw at all viewport widths larger than 640px

If the amount of child items is larger than the width of BaFlex, they will get wrapped onto the next line automatically. Just the same as a normal Flexbox container would with the flex-wrap: wrap; property.

Aligning a group of items in a row is as simple as wrapping them with the BaFlex component.

Group of aligned items
<BaFlex>
  <div></div>
  <div></div>
  <div></div>
</BaFlex>
Group of items aligned to the right
<BaFlex alignContent="right">
  <div></div>
  <div></div>
  <div></div>
</BaFlex>

The spacing (gutters) between the rows can be edited by passing a value to the rowGutter<viewport>vw props. Row gutters by default will match the gutters between columns at each viewport. If a row gutter has been set then that value will persist across all larger viewports ignoring the default row gutter values.

Setting the row gutter to the default (8px) at the 320px viewport and 16px at the 480px viewport and wider
<BaFlex rowGutter480vw="16"> ... </BaFlex>
Setting the row gutter to defaults at 320px & 480px viewports (8px and 16px) and 32px at the 640px viewport and wider
<BaFlex rowGutter640vw="32"> ... </BaFlex>
Setting the row gutter to 32px at the 480px viewport and then reducing to 24px at the 800px viewport and wider
<BaFlex rowGutter480vw="32" rowGutter800vw="24"> ... </BaFlex>

The spacing (gutters) between the columns can be edited by passing a value to the columnGutter<viewport>vw props. Column gutters by default will match the gutter between rows at each viewport. If a column gutter has been set then that value will persist across all larger viewports ignoring the default row gap values.

Setting the column gutter to the default (8px) at the 320px viewport and 16px at the 480px viewport and wider
<BaFlex columnGutter480vw="16"> ... </BaFlex>
Setting the column gutter to defaults at 320px & 480px viewports (8px and 16px) and 32px at the 640px viewport and wider
<BaFlex columnGutter640vw="32"> ... </BaFlex>
Setting the column gutter to 32px at the 480px viewport and then reducing to 24px at the 800px viewport and wider
<BaFlex columnGutter480vw="32" columnGutter800vw="24"> ... </BaFlex>
Prop Description Type Default
children Items laid out along the main axis. ReactNode
direction Main axis. "row" places children side by side. "column" stacks them.
Defaults to "row".
"row" | "column" row
alignItems Alignment on the cross axis: "flex-start", "flex-end", "center",
"stretch", or "baseline". A row uses this for vertical alignment.
A column uses it for horizontal alignment.
BaFlexAlignItems
justifyContent Alignment on the main axis: "flex-start", "flex-end", "center",
"space-between", "space-around", or "space-evenly". On a row,
"flex-end" matches web align-content="right".
BaFlexJustifyContent
wrap Wrap children onto the next line when they do not fit. Defaults to true. boolean true
columnGutter320vw Gap between columns from 320px wide. "8", "16", "24", or "32".
Wider breakpoints fall back to this when they are omitted. Defaults to "8".
BaFlexColumnGutter320vw 8
columnGutter480vw Gap between columns from 480px wide. "8", "16", "24", or "32".
Falls back to the next smaller column gutter when omitted.
BaFlexColumnGutter480vw
columnGutter640vw Gap between columns from 640px wide. "8", "16", "24", or "32".
Falls back to the next smaller column gutter when omitted.
BaFlexColumnGutter640vw
columnGutter800vw Gap between columns from 800px wide. "8", "16", "24", "32",
"40", or "64". Falls back to the next smaller column gutter when omitted.
BaFlexColumnGutter800vw
columnGutter1024vw Gap between columns from 1024px wide. "8", "16", "24", "32",
"40", "64", or "96". Falls back to the next smaller column gutter
when omitted.
BaFlexColumnGutter1024vw
rowGutter320vw Gap between rows from 320px wide. "8", "16", or "24". Wider
breakpoints fall back to this when they are omitted. Defaults to "8".
BaFlexRowGutter320vw 8
rowGutter480vw Gap between rows from 480px wide. "8", "16", or "24". Falls back to
the next smaller row gutter when omitted.
BaFlexRowGutter480vw
rowGutter640vw Gap between rows from 640px wide. "8", "16", or "24". Falls back to
the next smaller row gutter when omitted.
BaFlexRowGutter640vw
rowGutter800vw Gap between rows from 800px wide. "8", "16", "24", "32", or
"40". Falls back to the next smaller row gutter when omitted.
BaFlexRowGutter800vw
rowGutter1024vw Gap between rows from 1024px wide. "8", "16", "24", "32", or
"40". Falls back to the next smaller row gutter when omitted.
BaFlexRowGutter1024vw
testID Used to locate this view in end-to-end tests. string
accessibilityLabel Overrides the text that's read by the screen reader when the user interacts with the element. By default, the
label is constructed by traversing all the children and accumulating all the Text nodes separated by space.
string
accessibilityHint An accessibility hint helps users understand what will happen when they perform an action on the accessibility element when that result is not obvious from the accessibility label. string
accessibilityState Accessibility State tells a person using either VoiceOver on iOS or TalkBack on Android the state of the element currently focused on. AccessibilityState

BaFlex can be placed in:

All the column and row props on this component contain a number followed by vw which defines the viewport width (in pixels) that the value will be applied. The value provided will then persist at each wider viewport until another prop has been set.

For example setting columnGutter480vw and columnGutter640vw props will:

  • apply the default value for column gutters between viewport widths up to 479px
  • apply the value set in columnGutter480vw between viewport widths of 480px and 639px
  • apply the value set in columnGutter640vw at all viewport widths larger than 640px

If the amount of child items is larger than the width of BaFlex, they will get wrapped onto the next line automatically. Just the same as a normal Flexbox container would with the flex-wrap: wrap; property. Set wrap={false} to keep them on one line.

Aligning a group of items in a row is as simple as wrapping them with the BaFlex component. direction defaults to row. Set column to stack the children.

Group of aligned items
<BaFlex>
  <BaButton variant="secondary">One</BaButton>
  <BaButton variant="primary">Two</BaButton>
  <BaButton variant="secondary">Three</BaButton>
</BaFlex>

On a row, set justifyContent to flex-end. That matches alignContent="right" on web. alignItems aligns children on the cross axis.

Group of items aligned to the right
<BaFlex justifyContent="flex-end">
  <BaButton variant="secondary">Secondary</BaButton>
  <BaButton variant="primary">Primary</BaButton>
</BaFlex>

The spacing (gutters) between the rows can be edited by passing a value to the rowGutter<viewport>vw props. The default is 8px. If a row gutter has been set then that value will persist across all larger viewports.

Setting the row gutter to the default (8px) at the 320px viewport and 16px at the 480px viewport and wider
<BaFlex rowGutter480vw="16"> ... </BaFlex>
Setting the row gutter to the default (8px) at the 320px and 480px viewports and 24px at the 640px viewport and wider
<BaFlex rowGutter640vw="24"> ... </BaFlex>
Setting the row gutter to 32px at the 800px viewport and then reducing to 24px at the 1024px viewport and wider
<BaFlex rowGutter800vw="32" rowGutter1024vw="24"> ... </BaFlex>

The spacing (gutters) between the columns can be edited by passing a value to the columnGutter<viewport>vw props. The default is 8px. If a column gutter has been set then that value will persist across all larger viewports.

Setting the column gutter to the default (8px) at the 320px viewport and 16px at the 480px viewport and wider
<BaFlex columnGutter480vw="16"> ... </BaFlex>
Setting the column gutter to the default (8px) at the 320px and 480px viewports and 32px at the 640px viewport and wider
<BaFlex columnGutter640vw="32"> ... </BaFlex>
Setting the column gutter to 32px at the 480px viewport and then reducing to 24px at the 800px viewport and wider
<BaFlex columnGutter480vw="32" columnGutter800vw="24"> ... </BaFlex>

ba‑flex uses CSS flexbox which makes it easy to reverse and change the visual order that elements are displayed on the page. However visually re-arranging the UI so that it no longer matches the order of the source code causes accessibility issues.

Further reading:

State: ba-flex is a layout container

⇥ Tab

Focus moves through interactive child elements in DOM source order

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

  • ba-flex is used for arranging related items in a row that can wrap naturally onto new lines
  • Responsive spacing is configured with viewport-specific row-gutter and column-gutter attributes where needed
  • When using ba-image inside ba-flex, an explicit width is set so images render as expected
  • Visual order of items matches source order in the DOM
  • ba-flex is not used to reverse or reorder content in a way that conflicts with reading order
  • Keyboard focus order remains logical and follows source order across breakpoints

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

  • Gutter values apply correctly across breakpoints and persist until overridden
  • ba-flex layout does not cause clipped or overlapping content at common viewport sizes
  • Colour contrast for child content remains compliant in all BAgel themes
  • Animations respect users' reduced motion settings
  • High contrast mode adjustments
Designing Developing Components BAgel helper Web QA React Native QA britishairways.com Careers Cookie policy