Skip to content

Grid Template Columns

View raw .md

Utilities for specifying the columns in a grid layout.

On this page
Preview layout/grid_cols The live demo is not available for this example. grid_cols.dart View source
dart
// Basic grid with 3 columns
WDiv(
  className: 'grid grid-cols-3 gap-4',
  children: [
    WDiv(className: 'bg-blue-500 h-12'),
    WDiv(className: 'bg-blue-500 h-12'),
    WDiv(className: 'bg-blue-500 h-12'),
  ],
)

Basic Usage#

Use grid-cols-{n} to create a grid with n equally sized columns.

This utility must be used alongside the grid class (or inline-grid if supported) to activate the grid layout model.

dart
WDiv(
  className: 'grid grid-cols-4 gap-4',
  children: [
    // ... 4 items per row
  ],
)

Quick Reference#

Class Properties
grid-cols-1 crossAxisCount: 1
grid-cols-2 crossAxisCount: 2
grid-cols-3 crossAxisCount: 3
grid-cols-4 crossAxisCount: 4
grid-cols-5 crossAxisCount: 5
grid-cols-6 crossAxisCount: 6
grid-cols-12 crossAxisCount: 12

Responsive#

Prefix grid utilities with breakpoint variants like md: or lg: to change the column count at different screen sizes.

Preview layout/grid_responsive The live demo is not available for this example. grid_responsive.dart View source
dart
WDiv(
  className: 'grid grid-cols-1 md:grid-cols-3 lg:grid-cols-6 gap-4',
  children: [
    // 1 col on mobile, 3 on tablet, 6 on desktop
  ],
)

Dark Mode#

While column counts rarely change based on theme, you can use dark: if needed.

dart
WDiv(
  className: 'grid grid-cols-2 dark:grid-cols-4',
  children: [...],
)

Arbitrary Values#

Wind supports any integer for grid columns directly in the utility class. You do not need square brackets [] for this property.

dart
// Create a grid with exactly 16 columns
WDiv(
  className: 'grid grid-cols-16 gap-1',
  children: [...],
)
esc

Search index did not load.

No match for "".

Try a class like rounded-lg or a widget like WButton.