Skip to content

Grid

CSS Grid layout for creating responsive grids with equal-width columns or asymmetric layouts.

ClassPurposeColumnsExample
af-gridAuto-adjusting grid (recommended)Auto-fit (default)<div class="af-grid">
af-grid-11 equal column (explicit)1<div class="af-grid-1">
af-grid-22 equal columns (explicit)2<div class="af-grid-2">
af-grid-33 equal columns (explicit)3<div class="af-grid-3">
af-grid-44 equal columns (explicit)4<div class="af-grid-4">
af-grid-55 equal columns (explicit)5<div class="af-grid-5">
af-grid-66 equal columns (explicit)6<div class="af-grid-6">
af-grid-77 equal columns (explicit)7<div class="af-grid-7">
af-grid-88 equal columns (explicit)8<div class="af-grid-8">
af-grid-99 equal columns (explicit)9<div class="af-grid-9">
af-grid-1010 equal columns (explicit)10<div class="af-grid-10">
af-grid-1111 equal columns (explicit)11<div class="af-grid-11">
af-grid-1212 equal columns (explicit)12<div class="af-grid-12">

For equal-width columns, use af-grid-1 through af-grid-12:

<!-- 2 equal columns -->
<div class="af-grid-2">
  <div class="af-card">
    Item 1
  </div>
  <div class="af-card">
    Item 2
  </div>
</div>
<!-- 3 equal columns -->
<div class="af-grid-3">
  <div class="af-card">
    Item 1
  </div>
  <div class="af-card">
    Item 2
  </div>
  <div class="af-card">
    Item 3
  </div>
</div>

All grid classes support responsive variants. Use responsive suffixes for breakpoint-specific columns:

<!-- Auto-adjusting with responsive overrides -->
<div class="af-grid af-grid-1@sm af-grid-3@md af-grid-6@xl">
  <div class="af-card">
    Item 1
  </div>
  <div class="af-card">
    Item 2
  </div>
  <div class="af-card">
    Item 3
  </div>
  <div class="af-card">
    Item 4
  </div>
  <div class="af-card">
    Item 5
  </div>
  <div class="af-card">
    Item 6
  </div>
</div>
<!-- Explicit columns with responsive -->
<div class="af-grid-1 af-grid-2@md af-grid-4@lg">
  <div class="af-card">
    Item 1
  </div>
  <div class="af-card">
    Item 2
  </div>
  <div class="af-card">
    Item 3
  </div>
  <div class="af-card">
    Item 4
  </div>
</div>

Available responsive variants: All af-grid-1 through af-grid-12 support @xs, @sm, @md, @lg, @xl, and @2xl suffixes. Use af-grid as the default auto-fit grid.

Tip: New to the @{bp} syntax? See Responsive Suffix for breakpoints, patterns, and best practices.

Use af-gap-sm, af-gap-lg, etc. to override the default gap-md:

<div class="af-grid af-gap-lg">
  Large gap between columns
</div>
<div class="af-grid-2 af-gap-xl">
  Extra large gap
</div>

Note: af-grid-1 through af-grid-12 are standalone classes that include display: grid and gap-md automatically. You don’t need to combine them with af-grid.

Auto-adjusting: 2 children = 2 columns

50%

50%

Auto-adjusting: 3 children = 3 columns

33%

33%

33%

Explicit: 6 columns

1

2

3

4

5

6

For asymmetric layouts, use af-grid with af-col-span-* classes.

ClassPurposeUsage
af-col-span-1 through af-col-span-12Column spans (1-12)Use inside af-grid container
<div class="af-grid">
  <div class="af-col-span-8@lg">
    Main content (8/12)
  </div>
  <div class="af-col-span-4@lg">
    Sidebar (4/12)
  </div>
</div>

Mobile-first default: Items in a 12-column grid automatically default to full width (12 columns) on mobile. You only need to specify responsive spans for larger screens.

The pattern af-col-span-8@lg means:

  • Mobile (default): Full width (12 columns) - automatic
  • Large screens and up: 8 columns (two-thirds width)

Note: The base af-col-span-12 class exists for completeness but isn’t needed - full width is the automatic default. However, responsive variants like af-col-span-12@md are available if you need to explicitly set full width at a specific breakpoint (e.g., af-col-span-6 af-col-span-12@md for “half width on mobile, full width on medium+”).

ClassSpansExampleUse Case
af-col-span-11 column<div class="af-col-span-1">Narrow column
af-col-span-22 columns<div class="af-col-span-2">Small column
af-col-span-33 columns<div class="af-col-span-3">Quarter width
af-col-span-44 columns<div class="af-col-span-4">One-third width
af-col-span-55 columns<div class="af-col-span-5">Custom width
af-col-span-66 columns (half width)<div class="af-col-span-6">Half width
af-col-span-77 columns<div class="af-col-span-7">Custom width
af-col-span-88 columns (two-thirds)<div class="af-col-span-8">Two-thirds width
af-col-span-99 columns<div class="af-col-span-9">Three-quarters width
af-col-span-1010 columns<div class="af-col-span-10">Custom width
af-col-span-1111 columns<div class="af-col-span-11">Custom width
af-col-span-1212 columns (full width)<div class="af-col-span-12">Full width (exists but not needed - default)

Note: Full width (12 columns) is the default - no class needed. The af-col-span-12 class exists for completeness but isn’t recommended. For explicit full width at breakpoints, use responsive variants: af-col-span-12@md, af-col-span-12@lg, etc.

Responsive: All spans support responsive suffixes: af-col-span-6@md, af-col-span-8@lg, af-col-span-12@md, etc. Items default to full width on mobile, so you only need responsive classes for larger screens.

Main content (8 columns on large screens)

Sidebar (4 columns on large screens)