ba-grid
This component provides the internal structure of our pages by aligning elements to our grid and automatically setting the correct sizes and spacing
Airframe
Web Components
React
React Native
Anatomy
Parent ba-grid
The outer container that holds the grid’s child elements and arranges them into rows.
Row gutters
The vertical space between rows. Row gutter sizes can be configured for different viewports.
Nested three-column ba-grid
A nested ba-grid that arranges its child elements into three equal-width columns. This ba-grid also controls the column gutters within the row.
Nested wide–narrow ba-grid
A nested ba-grid with a wider first column and a narrower second column. This ba-grid also controls the column gutter within the row.
Nested two-column ba-grid
A nested ba-grid that arranges its child elements into two equal-width columns. This ba-grid also controls the column gutter within the row.
Live Demo
<ba-grid>
<ba-grid columns-800vw="1:2">
<div class="placeholder"></div>
<div class="placeholder"></div>
</ba-grid>
<ba-grid columns-800vw="2:1">
<div class="placeholder placeholder--full"></div>
<ba-grid>
<div class="placeholder"></div>
<div class="placeholder"></div>
</ba-grid>
</ba-grid>
</ba-grid>
Properties and attributes
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
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 |
undefined |
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 |
columns1024vw |
columns-1024vw |
Set's the column layout at 1024px and wider. Accepts a single number or two numbers separated with a colon | string | undefined |
undefined |
columns320vw |
columns-320vw |
Set's the column layout at 320px and wider. Accepts a single number or two numbers separated with a colon | string | undefined |
undefined |
columns480vw |
columns-480vw |
Set's the column layout at 480px and wider. Accepts a single number or two numbers separated with a colon | string | undefined |
undefined |
columns640vw |
columns-640vw |
Set's the column layout at 640px and wider. Accepts a single number or two numbers separated with a colon | string | undefined |
undefined |
columns800vw |
columns-800vw |
Set's the column layout at 800px and wider. Accepts a single number or two numbers separated with a colon | string | 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 |
undefined |
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 |
Permitted ARIA roles
- list
- listitem
Slots
Parent components
ba-grid can be slotted into:
<ba‑accordion><ba‑card><ba‑card‑segmented><ba‑checkbox‑card><ba‑checkbox‑list‑card><ba‑details><ba‑form><ba‑form‑group><ba‑grid><ba‑header‑section><ba‑hero><ba‑input‑password><ba‑media‑object><ba‑message><ba‑message‑global><ba‑page‑segment><ba‑radio‑card><ba‑tab‑container‑content><ba‑tab‑chip‑content>
Usage
Classes
The following classes can be used to position child elements within a cell:
- ba-c-grid--top-left
- ba-c-grid--top-center
- ba-c-grid--top-right
- ba-c-grid--middle-left
- ba-c-grid--center
- ba-c-grid--middle-right
- ba-c-grid--bottom-left
- ba-c-grid--bottom-center
- ba-c-grid--bottom-right
Overview
All properties 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 property has been set.
For example setting columns-480vw and columns-640vw attributes will:
- apply the default value for columns between viewport widths up to 479px
- apply the value set in
columns-480vwbetween viewport widths of 480px and 639px - apply the value set in
columns-640vwat all viewport widths larger than 640px
Equal width columns
Applying a single number to the columns-<viewport>vw attributes will split the contents of ba-grid into that many columns with each column having the same width.
<ba-grid columns-640vw="2"> ... </ba-grid>
<ba-grid columns-640vw="2" columns-800vw="3" columns-1024vw="4"> ... </ba-grid>
<ba-grid columns-800vw="4" columns-1024vw="3"> ... </ba-grid>
Spanning columns
A ratio can be passed to the columns-<viewport>vw attributes to create layouts that span multiple columns.
The ratio is in the format A:B where:
- The total number of columns is the sum of numberA and numberB in the ratio
- Odd child elements will span numberA columns of the total number of columns
- Even child elements will span numberB columns of the total number of columns
<ba-grid columns-800vw="1:2">
<div><!-- Spans 1 of 3 columns --> </div>
<div><!-- Spans 2 of 3 columns --> </div>
<div><!-- Spans 1 of 3 columns --> </div>
<div><!-- Spans 2 of 3 columns --> </div>
...
</ba-grid>
<ba-grid columns-480vw="2" columns-640vw="2:1" columns-1024vw="3:2">
<div><!-- 1 column, then 1 of 2 columns, then spans 2 of 3 columns, then spans 3 of 5 columns --> </div>
<div><!-- 1 column, then 2 of 2 columns, then spans 1 of 3 columns, then spans 2 of 5 columns --> </div>
<div><!-- 1 column, then 1 of 2 columns, then spans 2 of 3 columns, then spans 3 of 5 columns --> </div>
<div><!-- 1 column, then 2 of 2 columns, then spans 1 of 3 columns, then spans 2 of 5 columns --> </div>
...
</ba-grid>
Setting row spacing
The spacing (gutters) between the rows can be edited by passing a value to the row-gutter-x properties. 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.
<ba-grid row-gutter-480vw="16"> ... </ba-grid>
<ba-grid row-gutter-640vw="32"> ... </ba-grid>
<ba-grid row-gutter-480vw="32" row-gutter-800vw="24"> ... </ba-grid>
Setting column spacing
The spacing (gutters) between the columns can be edited by passing a value to the column-gutter-x properties. 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.
<ba-grid column-gutter-480vw="16"> ... </ba-grid>
<ba-grid column-gutter-640vw="32"> ... </ba-grid>
<ba-grid column-gutter-480vw="32" column-gutter-800vw="24"> ... </ba-grid>
Nesting ba-grid inside another ba-grid
ba-grid can be nested within itself to create more complex layouts
<ba-grid columns-1024vw="2:1">
<div>
<!-- main content -->
</div>
<ba-grid columns-640vw="3" columns-1024vw="1" row-gutter-1024vw="16" role="list">
<!-- additional content -->
<div role="listitem">...</div>
<div role="listitem">...</div>
<div role="listitem">...</div>
</ba-grid>
</ba-grid>
Positioning elements within ba-grid
Elements can be positioned in the space that they have available. Available space in a cell is calculated by the highest element in a row and the widest element in a column (note this can also be the element that you want to position)
<ba-grid columns-1024vw="2:1">
<ba-content>
<!-- some content placed here -->
</ba-content>
<ba-image class="ba-c-grid--middle-left" src="/url" alt="alt text"></ba-image>
</ba-grid>
Guidelines
ba‑grid uses CSS grid 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:
This helps screen readers understand that the elements are grouped and should be treated as a list
Further reading:
Keyboard navigation
State: ba-grid is a layout container
Focus moves through child elements in source order, not affected by visual grid positioning
Usage and accessibility checklist
Use this checklist to confirm the component has been configured and used correctly.
UX checklist
- ba-grid is used to create consistent layouts that align with the design system grid structure
- Test responsive behavior at many breakpoints from 320px to 1920px (and larger) and ensure content is displayed correctly
- Nested ba-grid components are used appropriately to create complex layouts without overcomplicating structure
- Column spanning ratios create logical visual hierarchy and grouping
Accessibility checklist
- Visual order of grid elements matches the source order in the DOM
- ba-grid does not use CSS to reverse or change the order of content in a way that differs from source order
- For multiple items, role="list" is applied to ba-grid and each child element has role="listitem"
- Grid layout does not obscure or hide content at any viewport size
- Content within grid cells is accessible to keyboard navigation in the correct sequence
These checks are handled by the component and do not need to be repeated each time it is used.
- Grid gutters and column configurations are applied correctly at each viewport breakpoint