Grid
<gcds-grid>
-
GitHub -
Figma
Grid component preview
On this page
Coding and accessibility for grids
Adjust layouts to optimize the experience on different screen sizes
- Optimize each grid component for the different screen sizes a person will use — or switch between — when they visit your site or use your product.
- Adapt for mobile, tablet, and large screens by defining each viewport layout for that grid component.
- Smaller screens, like mobile devices, typically display a single column layout.
- Medium-sized screens, like tablets, a single or 2-column layout.
- Larger screens, like desktop, a 3- or 4- column layout.
- Use the
columnsproperty to add your layout for smaller screens or if you are using the same layout for all screens. - Use the
columns-tabletproperty to set your tablet layout (48em and 768px and above) or if you are using the same layout for medium and large screens. - Use the
columns-desktopproperty to define your layout for larger screens (64em and 1024px and above).
Maintain standard tag usage to be accessible
tag property is set to use a div tag. - Opt to change the tag to a context-appropriate value using standard tags. For example, when using an unordered list set the tag property to
ul. - Choose a tag from the list of available options for grid in the code builder. Using established standards for HTML tags that are semantic increase the accessibility of the content and improves the experience for everyone.
Add spacing between columns
- Use the
gapproperty to add spacing between yourcolumnsin the grid. - Use GC Design System design tokens as a reference for the size of the
gapin the grid. The tokens measurements match up with the spacing values for thegapattribute (150-800).
Choose an option for equal width columns
This is some example content to display the grid component.
This is some example content to display the grid component.
This is some example content to display the grid component.
This is some example content to display the grid component.
This is some example content to display the grid component.
This is some example content to display the grid component.
This is some example content to display the grid component.
This is some example content to display the grid component.
This is some example content to display the grid component.
<gcds-grid tag="article" columns-desktop="1fr 1fr 1fr" columns-tablet="1fr 1fr" columns="1fr">
<p>This is some example content to display the grid component.</p>
<p>This is some example content to display the grid component.</p>
<p>This is some example content to display the grid component.</p>
</gcds-grid>
- Set a minimum width when you want to prevent a column from being too narrow in smaller viewports.
- Set a maximum width when you want to prevent a column from being too wide in larger viewports.
This is some example content to display the grid component.
This is some example content to display the grid component.
This is some example content to display the grid component.
This is some example content to display the grid component.
This is some example content to display the grid component.
This is some example content to display the grid component.
This is some example content to display the grid component.
This is some example content to display the grid component.
This is some example content to display the grid component.
<gcds-grid tag="article" columns="repeat(auto-fit, minmax(100px, 300px))">
<p>This is some example content to display the grid component.</p>
<p>This is some example content to display the grid component.</p>
<p>This is some example content to display the grid component.</p>
</gcds-grid>
Examples
In this section
Optional attributes
align-content
align-content attribute sets the alignment of the grid along the block (column) axis when the total grid size is less than the size of its grid container. The available options are: centerendspace-aroundspace-betweenspace-evenlystartstretch
1
2
3
4
5
6
<gcds-grid align-content="space-between" columns-tablet="1fr 1fr 1fr" columns="1fr">
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
</gcds-grid> align-items
align-items attribute sets the alignment of grid items along the block (column) axis. The available options are: baselinecenterendstartstretch
1
2
3
<gcds-grid align-items="baseline" columns-tablet="1fr 1fr 1fr" columns="1fr">
<p>1</p>
<p class="pb-800">2</p>
<p class="pt-900">3</p>
</gcds-grid> alignment
alignment attribute sets the grid’s alignment if the grid container’s size is smaller than the parent’s size. The available options are: centerendstart
1
2
3
<gcds-grid alignment="end" container="sm" columns-tablet="1fr 1fr 1fr" columns="1fr">
<p>1</p>
<p>2</p>
<p>3</p>
</gcds-grid> columns
columns attribute defines the default number of grid columns for all viewports if columns-tablet and columns-desktop are not defined. Option to set different layouts for desktop with columns-desktop and for tablet with columns-tablet. 1
2
3
<gcds-grid columns="1fr 1fr">
<p>1</p>
<p>2</p>
<p>3</p>
</gcds-grid> columns-desktop
columns-desktop attribute provides the option to set a different number of grid columns for desktop screens. 1
2
3
<gcds-grid columns-desktop="1fr 1fr 1fr" columns-tablet="1fr 1fr 1fr" columns="1fr">
<p>1</p>
<p>2</p>
<p>3</p>
</gcds-grid> columns-tablet
columns-tablet attribute provides the option to set a different number of grid columns for tablet screens. If columns-desktop is not defined, columns-tablet will be used to define the number of columns for desktop as well. 1
2
3
<gcds-grid columns-tablet="1fr 1fr" columns="1fr">
<p>1</p>
<p>2</p>
<p>3</p>
</gcds-grid> container
container attribute defines the grid container size. The available options are: fullxllgmdsmxs
1
2
3
<gcds-grid container="sm" columns-tablet="1fr 1fr 1fr" columns="1fr">
<p>1</p>
<p>2</p>
<p>3</p>
</gcds-grid> display
display attribute defines the element as a grid or inline-grid container. The available options are: grid(default)inline-grid
1
2
3
<gcds-grid display="inline-grid" columns-tablet="1fr 1fr 1fr" columns="1fr">
<p>1</p>
<p>2</p>
<p>3</p>
</gcds-grid> gap
gap attribute defines the horizontal and vertical spacing between items in a grid container for all viewports if gap-tablet and gap-desktop are not defined. Option to set different spacing for desktop with gap-desktop and for tablet with gap-tablet. 1
2
3
4
5
6
<gcds-grid gap="450" columns-tablet="1fr 1fr 1fr" columns="1fr">
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
</gcds-grid> gap-desktop
gap-desktop attribute provides the option to set horizontal and vertical spacing between items in a grid container for desktop screens. 1
2
3
4
5
6
<gcds-grid gap-desktop="800" gap="400" columns-tablet="1fr 1fr 1fr" columns="1fr">
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
</gcds-grid> gap-tablet
gap-tablet attribute provides the option to set horizontal and vertical spacing between items in a grid container for tablet screens. If gap-desktop is not defined, gap-tablet will be used to define the spacing for desktop screens as well. 1
2
3
4
5
6
<gcds-grid gap-tablet="500" gap="400" columns-tablet="1fr 1fr 1fr" columns="1fr">
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
</gcds-grid> justify-content
justify-content attribute sets the alignment of the grid along the inline (row) axis if the total grid size is less than the size of its grid container. The available options are: centerendspace-aroundspace-betweenspace-evenlystartstretch
1
2
3
<gcds-grid justify-content="center" columns-tablet="1fr 1fr 1fr" columns="1fr">
<p>1</p>
<p>2</p>
<p>3</p>
</gcds-grid> justify-items
justify-items attribute sets the alignment of the grid items along the inline (row) axis. The available options are: centerendstartstretch
1
2
3
<gcds-grid justify-items="center" columns-tablet="1fr 1fr 1fr" columns="1fr">
<p>1</p>
<p>2</p>
<p>3</p>
</gcds-grid> place-content
place-content attribute sets both the align-content and justify-content attributes. The available options are: centerendspace-aroundspace-betweenspace-evenlystartstretch
1
2
3
4
5
6
<gcds-grid place-content="space-around" columns-tablet="1fr 1fr 1fr" columns="1fr">
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
</gcds-grid> place-items
place-items attribute sets both the align-items and justify-items attributes. The available options are: centerendstartstretch
1
2
3
4
5
6
<gcds-grid place-items="end" columns-tablet="1fr 1fr 1fr" columns="1fr">
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
</gcds-grid> tag
tag attribute sets the HTML element used to render the grid container. By default, it is set to div. The available options are: div(default)articleasidedlmainnavolsectionul
1
2
3
<gcds-grid tag="article" columns-tablet="1fr 1fr 1fr" columns="1fr">
<p>1</p>
<p>2</p>
<p>3</p>
</gcds-grid> Slots
default
default slot is for placing the grid items. 1
2
3
<gcds-grid columns-tablet="1fr 1fr 1fr" columns="1fr">
<p>1</p>
<p>2</p>
<p>3</p>
</gcds-grid> - Explore by choosing different code values to generate the instance you want.
- Get the code and pull it into your environment.
- Add any copy you need to the component (like text for a label).
This is some example content to display the grid component.
This is some example content to display the grid component.
This is some example content to display the grid component.
This is some example content to display the grid component.