flex-shrink

Class Description

shrink

Lets a flex item shrink by the --shrink factor when space is limited.

CSS Rules

.shrink {
  flex-shrink: var(--shrink);
}

Usage

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

Responsive

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

<element class="md:shrink" style="--md-shrink: /* 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="shrink:hover" style="--shrink-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="shrink: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 shrink::before" style="--shrink-before: /* value */;" />

<element class="content-after shrink::after" style="--shrink-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="shrink=value" />

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

CLS Alert

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

.shrink Lets a flex item shrink by the --shrink factor when space is limited.

shrink-1

Sets flex-shrink: 1. Item shrinks when space is limited.

CSS Rules

.shrink-1 {
  flex-shrink: 1;
}

Usage

<element class="shrink-1" />

Responsive

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

<element class="md:shrink-1" />

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="shrink-1: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="shrink-1: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 shrink-1::before" />

<element class="content-after shrink-1::after" />
.shrink-1 Sets flex-shrink: 1. Item shrinks when space is limited.

shrink-0

Sets flex-shrink: 0. Item will not shrink.

CSS Rules

.shrink-0 {
  flex-shrink: 0;
}

Usage

<element class="shrink-0" />

Responsive

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

<element class="md:shrink-0" />

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="shrink-0: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="shrink-0: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 shrink-0::before" />

<element class="content-after shrink-0::after" />
.shrink-0 Sets flex-shrink: 0. Item will not shrink.