grid-template-columns

Class Description

grid-cols

Sets grid-template-columns with N equal columns via --grid-cols. Use [grid-cols] for custom track definitions.

CSS Rules

.grid-cols {
  grid-template-columns: repeat(var(--grid-cols), minmax(0, 1fr));
}

Usage

The .grid-cols class is flagged as a value-driven selector. The variable --grid-cols is required.
<element class="grid-cols" style="--grid-cols: /* value */;" />

Responsive

Prefix .grid-cols utility with a breakpoint variant (e.g., md:) to apply styles at specific screen sizes (Supported breakpoints are xm through 2xl).

<element class="md:grid-cols" style="--md-grid-cols: /* value */;" />

States

States are generated dynamically at runtime and always come last. Append a state like :hover or :focus to the end of the class. This works in conjunction with breakpoints .

Supported pseudo-classes: :hover, :active, :focus, :focus-visible, :focus-within, :target, :checked, :disabled, and :group-hover.

<element class="grid-cols:hover" style="--grid-cols-hover: /* value */;" />

Group Hover Example

The :group-hover state applies styles when a parent element with the .group class is hovered.

<element class="group">
  <element class="grid-cols:group-hover">...</element>
</element>

Pseudo-Elements

The ::before and ::after utility classes are supported too. Granted that you add the mandatory content-before or content-after class in order for them to work.

<element class="content-before grid-cols::before" style="--grid-cols-before: /* value */;" />

<element class="content-after grid-cols::after" style="--grid-cols-after: /* value */;" />

Shorthand

Value-driven classes support a shorthand syntax like bg=pink or p=4. The runtime processes this for you. Unlike :hover that is generating CSS on the fly, shorthand only splits it and appends the corresponding style.

<!-- Input -->
<element class="grid-cols=value" />

<!-- Output -->
<element class="grid-cols" style="--grid-cols: value;" />

CLS Alert

This feature may cause CLS (Cumulative Layout Shift). Make sure to include a z-not-ready class in your <head> tag.

.grid-cols Sets grid-template-columns with N equal columns via --grid-cols. Use [grid-cols] for custom track definitions.

[grid-cols]

Defines grid column tracks using raw --grid-cols. Useful for custom grid templates.

CSS Rules

.\[grid-cols\] {
  grid-template-columns: var(--grid-cols);
}

Usage

The .[grid-cols] class is flagged as a value-driven selector. The variable --grid-cols is required.
<element class="[grid-cols]" style="--grid-cols: /* value */;" />

Responsive

Prefix .[grid-cols] utility with a breakpoint variant (e.g., md:) to apply styles at specific screen sizes (Supported breakpoints are xm through 2xl).

<element class="md:[grid-cols]" style="--md-grid-cols: /* value */;" />

States

States are generated dynamically at runtime and always come last. Append a state like :hover or :focus to the end of the class. This works in conjunction with breakpoints .

Supported pseudo-classes: :hover, :active, :focus, :focus-visible, :focus-within, :target, :checked, :disabled, and :group-hover.

<element class="[grid-cols]:hover" style="--grid-cols-hover: /* value */;" />

Group Hover Example

The :group-hover state applies styles when a parent element with the .group class is hovered.

<element class="group">
  <element class="[grid-cols]:group-hover">...</element>
</element>

Pseudo-Elements

The ::before and ::after utility classes are supported too. Granted that you add the mandatory content-before or content-after class in order for them to work.

<element class="content-before [grid-cols]::before" style="--grid-cols-before: /* value */;" />

<element class="content-after [grid-cols]::after" style="--grid-cols-after: /* value */;" />

Shorthand

Value-driven classes support a shorthand syntax like bg=pink or p=4. The runtime processes this for you. Unlike :hover that is generating CSS on the fly, shorthand only splits it and appends the corresponding style.

<!-- Input -->
<element class="[grid-cols]=value" />

<!-- Output -->
<element class="[grid-cols]" style="--grid-cols: value;" />

CLS Alert

This feature may cause CLS (Cumulative Layout Shift). Make sure to include a z-not-ready class in your <head> tag.

.[grid-cols] Defines grid column tracks using raw --grid-cols. Useful for custom grid templates.

grid-cols-none

Removes grid-template-columns.

CSS Rules

.grid-cols-none {
  grid-template-columns: none;
}

Usage

<element class="grid-cols-none" />

Responsive

Prefix .grid-cols-none utility with a breakpoint variant (e.g., md:) to apply styles at specific screen sizes (Supported breakpoints are xm through 2xl).

<element class="md:grid-cols-none" />

States

States are generated dynamically at runtime and always come last. Append a state like :hover or :focus to the end of the class. This works in conjunction with breakpoints .

Supported pseudo-classes: :hover, :active, :focus, :focus-visible, :focus-within, :target, :checked, :disabled, and :group-hover.

<element class="grid-cols-none:hover" />

Group Hover Example

The :group-hover state applies styles when a parent element with the .group class is hovered.

<element class="group">
  <element class="grid-cols-none:group-hover">...</element>
</element>

Pseudo-Elements

The ::before and ::after utility classes are supported too. Granted that you add the mandatory content-before or content-after class in order for them to work.

<element class="content-before grid-cols-none::before" />

<element class="content-after grid-cols-none::after" />
.grid-cols-none Removes grid-template-columns.

grid-cols-subgrid

Sets grid-template-columns: subgrid. Inherits column tracks from the parent grid.

CSS Rules

.grid-cols-subgrid {
  grid-template-columns: subgrid;
}

Usage

<element class="grid-cols-subgrid" />

Responsive

Prefix .grid-cols-subgrid utility with a breakpoint variant (e.g., md:) to apply styles at specific screen sizes (Supported breakpoints are xm through 2xl).

<element class="md:grid-cols-subgrid" />

States

States are generated dynamically at runtime and always come last. Append a state like :hover or :focus to the end of the class. This works in conjunction with breakpoints .

Supported pseudo-classes: :hover, :active, :focus, :focus-visible, :focus-within, :target, :checked, :disabled, and :group-hover.

<element class="grid-cols-subgrid:hover" />

Group Hover Example

The :group-hover state applies styles when a parent element with the .group class is hovered.

<element class="group">
  <element class="grid-cols-subgrid:group-hover">...</element>
</element>

Pseudo-Elements

The ::before and ::after utility classes are supported too. Granted that you add the mandatory content-before or content-after class in order for them to work.

<element class="content-before grid-cols-subgrid::before" />

<element class="content-after grid-cols-subgrid::after" />
.grid-cols-subgrid Sets grid-template-columns: subgrid. Inherits column tracks from the parent grid.