# Grid columns

> Set the number of equal columns of a CSS grid with one class, make an item span the full row, and change both per breakpoint.

Utility classes for the grid-template-columns property and for spanning all columns of a CSS grid.

Source: https://docs.tabler.io/ui/utilities/grid-columns

---

Use `.grid-cols-*` on an element with `.d-grid` to set its columns. Choose `1`, `2`, `3`, `4`, or `6` equal columns, or `subgrid` to reuse the columns of the parent grid.

## Columns

```html
<div class="d-grid grid-cols-3 gap-2">
  <div class="p-2 bg-primary-lt rounded">One</div>
  <div class="p-2 bg-primary-lt rounded">Two</div>
  <div class="p-2 bg-primary-lt rounded">Three</div>
  <div class="p-2 bg-primary-lt rounded">Four</div>
  <div class="p-2 bg-primary-lt rounded">Five</div>
  <div class="p-2 bg-primary-lt rounded">Six</div>
</div>
```

## Full width item

`.grid-cols-fill` makes an item span all columns of the grid.

```html
<div class="d-grid grid-cols-3 gap-2">
  <div class="grid-cols-fill p-2 bg-primary-lt rounded">Spans all columns</div>
  <div class="p-2 bg-primary-lt rounded">One</div>
  <div class="p-2 bg-primary-lt rounded">Two</div>
  <div class="p-2 bg-primary-lt rounded">Three</div>
</div>
```

## Subgrid

`.grid-cols-subgrid` makes a nested grid use the column tracks of its parent. Combine it with `.grid-cols-fill` to place the nested grid across the parent.

```html
<div class="d-grid grid-cols-3 gap-2">
  <div class="d-grid grid-cols-subgrid grid-cols-fill gap-2">
    <div class="p-2 bg-primary-lt rounded">One</div>
    <div class="p-2 bg-primary-lt rounded">Two</div>
    <div class="p-2 bg-primary-lt rounded">Three</div>
  </div>
</div>
```

## Responsive

All classes have responsive variants, for example `.grid-cols-md-4` or `.grid-cols-lg-fill`.

```html
<div class="d-grid grid-cols-1 grid-cols-md-2 grid-cols-lg-4 gap-2">...</div>
```

## Accessibility

- Columns change the layout only, not the reading order. Screen readers and keyboard focus still follow the order in the markup.
