object-fit

Class Description

object-contain

Sets object-fit: contain. Image fits inside container, letterboxed.

CSS Rules

.object-contain {
  object-fit: contain;
}

Usage

<element class="object-contain" />

Responsive

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

<element class="md:object-contain" />

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="object-contain: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="object-contain: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 object-contain::before" />

<element class="content-after object-contain::after" />
.object-contain Sets object-fit: contain. Image fits inside container, letterboxed.

object-cover

Sets object-fit: cover. Image fills container, cropping if needed.

CSS Rules

.object-cover {
  object-fit: cover;
}

Usage

<element class="object-cover" />

Responsive

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

<element class="md:object-cover" />

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="object-cover: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="object-cover: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 object-cover::before" />

<element class="content-after object-cover::after" />
.object-cover Sets object-fit: cover. Image fills container, cropping if needed.

object-fill

Sets object-fit to fill, stretching the element's content to fit its container.

CSS Rules

.object-fill {
  object-fit: fill;
}

Usage

<element class="object-fill" />

Responsive

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

<element class="md:object-fill" />

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="object-fill: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="object-fill: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 object-fill::before" />

<element class="content-after object-fill::after" />
.object-fill Sets object-fit to fill, stretching the element's content to fit its container.

object-none

Sets object-fit to none, maintaining the element's original size.

CSS Rules

.object-none {
  object-fit: none;
}

Usage

<element class="object-none" />

Responsive

Prefix .object-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:object-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="object-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="object-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 object-none::before" />

<element class="content-after object-none::after" />
.object-none Sets object-fit to none, maintaining the element's original size.

object-scale-down

Sets object-fit to scale-down, behaving as either none or contain depending on which is smaller.

CSS Rules

.object-scale-down {
  object-fit: scale-down;
}

Usage

<element class="object-scale-down" />

Responsive

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

<element class="md:object-scale-down" />

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="object-scale-down: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="object-scale-down: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 object-scale-down::before" />

<element class="content-after object-scale-down::after" />
.object-scale-down Sets object-fit to scale-down, behaving as either none or contain depending on which is smaller.