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.
<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
| Class | CSS declarations |
|---|---|
bg-auto | background-size: auto; |
bg-cover | background-size: cover; |
bg-contain | background-size: contain; |
bg-[size:16px_16px] | background-size: 16px 16px; |
View full generated CSS
.bg-\[size\:16px_16px\] {
background-size: 16px 16px;
}
.bg-auto {
background-size: auto;
}
.bg-contain {
background-size: contain;
}
.bg-cover {
background-size: cover;
}