Skip to content
SiteEmail

Column

The Column components are structural elements designed to create grid layouts when used in conjunction with the Row component. Each Column component represents a fraction of the row’s width, ranging from Column.One (1/12th of the row’s width) to Column.Twelve (the entire row’s width).

These components leverage a flexbox-based grid system, making it easy to create responsive layouts.

The primary use case for the Column components is to define the width of content within a Row component. If you don’t specify a size, <Column> equals <Column.Twelve>.

import Row from '@components/Layout/Row/Row';
import Column from "@components/Layout/Column/Column";
const App = () => {
return (
<Row>
<Column.Two>I take 2/12 of the row</Column.Two>
<Column.Ten>I take 10/12 of the row</Column.Ten>
</Row>
<Row>
<Column.Twelve>I take the full row</Column.Twelve>
</Row>
<Row>
<Column>I also take the full row</Column>
</Row>
);
};
export default App;

You can also nest rows and columns to create more complex layouts.

import Row from '@components/Layout/Row/Row';
import Column from "@components/Layout/Column/Column";
const App = () => {
return (
<Row>
<Column.Six>
<Row>
<Column>Nested column</Column>
</Row>
</Column.Six>
</Row>
);
};
export default App;
Prop NameTypeDefaultDescription
styleJSX.CSSProperties{}Inline styles to apply directly to the component’s root element.
classstring""Additional CSS classes to apply to the component
refHTMLDivElementundefinedRetrieves the component’s DOM element and assigns it to a variable.
onActionRecord<string, (scope?: string, ...args: any[]) => void>undefinedAllows you to add custom navigation action handlers to the component. See the Navigation component documentation for details.
anchorstring | HTMLElementundefinedLinks navigation to another element. When the anchor element is focused, this component’s actions will execute. Can be a CSS selector or HTMLElement.

The Column components define the width of their content within a Row. The predefined components (Column.One to Column.Twelve) correspond to fractions of the row’s total width. For example:

  • Column.One: 1/12th of the row’s width (8.33333%).
  • Column.Six: Half of the row’s width (50%).
  • Column.Twelve or just Column: Full row width (100%).
import Row from '@components/Layout/Row/Row';
import Column from "@components/Layout/Column/Column";
const App = () => {
return (
<Row>
<Column.One>I take 8.33333% of the row</Column.One>
<Column.One>I take 8.33333% of the row</Column.One>
<Column.One>I take 8.33333% of the row</Column.One>
<Column.One>I take 8.33333% of the row</Column.One>
<Column.One>I take 8.33333% of the row</Column.One>
<Column.One>I take 8.33333% of the row</Column.One>
<Column.Six>I take 50% of the row</Column.Six>
</Row>
<Row>
<Column.Twelve>I take 100% of the row</Column.Twelve>
</Row>
);
};
export default App;

To access the HTML DOM element of the Column component:

  1. Declare a variable to hold the ref but don’t initialize it with a value.
  2. The declared value should have a type of HTMLDivElement.
  3. Set the declared variable as the value of the ref prop of the Column component.
import Row from '@components/Layout/Row/Row';
import Column from "@components/Layout/Column/Column";
const App = () => {
let columnRef!: HTMLDivElement
return (
<Row>
<Column.Two ref={columnRef}>I take 2/12 of the row</Column.Two>
</Row>
);
};
export default App;

Now you can access the HTML element of Column with columnRef and make modifications to it if needed.