1. Backgrounds
  2. background-size

Backgrounds

background-size

Utilities for adjusting how a background image is scaled to fit inside its box.

ClassStyles
bg-auto
background-size: auto;
bg-cover
background-size: cover;
bg-contain
background-size: contain;
bg-size-(<custom-property>)
background-size: var(<custom-property>);
bg-size-[<value>]
background-size: <value>;

Examples

Covering the full area

Reach for the bg-cover utility to grow the background image until it blankets the whole layer, trimming any overflow along the way:

<div class="bg-[url(/img/mountains.jpg)] bg-cover bg-center"></div>

Fitting inside the edges

Reach for the bg-contain utility to fit the background image to the outer edges without any cropping or stretching:

<div class="bg-[url(/img/mountains.jpg)] bg-contain bg-center"></div>

Showing at natural size

Reach for the bg-auto utility to paint the background image at its default size:

<div class="bg-[url(/img/mountains.jpg)] bg-auto bg-center bg-no-repeat"></div>

Setting a custom value

Reach for the bg-size-[<value>] syntax to define the background size from any fully custom value:

<div class="bg-size-[auto_100px] ...">  <!-- ... --></div>

For CSS variables, you can also reach for the bg-size-(<custom-property>) syntax:

<div class="bg-size-(--my-image-size) ...">  <!-- ... --></div>

Think of this as a tidy shorthand for bg-size-[var(<custom-property>)] that wires up the var() function on your behalf.

Responsive behavior

Add a breakpoint variant such as md: in front of a background-size utility so it kicks in only at medium screens and larger:

<div class="bg-auto md:bg-contain ...">  <!-- ... --></div>

Dig deeper into working with variants in the variants reference.

Design interfaces people love — 5-day mini-course

5-part crash course

Ship UIs you’re proud of.

Bite-sized, hands-on video lessons from the team behind Breezel, dropped straight into your inbox every day for a week.

Grab the free series

Copyright © 2026 Breezel, Inc.·Trademark Policy