Browse documentation

Reference / Backgrounds

Background size

Scale a background to fill its box, fit within it, or repeat as a tile of a fixed size.

Working example

A repeating background can use a two-value size to define its tile width and height. The size type hint distinguishes the declaration from a background color.

HTML
<div role="img" aria-label="Dot grid" class="h-20 border
  bg-[radial-gradient(circle,#444_1px,transparent_1.5px)] bg-[size:12px_12px]"></div>

Class reference

ClassCSS declarations
bg-autobackground-size: auto;
bg-coverbackground-size: cover;
bg-containbackground-size: contain;
bg-[size:16px_16px]background-size: 16px 16px;
View full generated CSS
Compiled CSS
.bg-\[size\:16px_16px\] {
  background-size: 16px 16px;
}
.bg-auto {
  background-size: auto;
}
.bg-contain {
  background-size: contain;
}
.bg-cover {
  background-size: cover;
}