Backgrounds
Handy classes for deciding how an element's background image tiles and repeats.
| Class | Styles |
|---|---|
| bg-repeat | background-repeat: repeat; |
| bg-repeat-x | background-repeat: repeat-x; |
| bg-repeat-y | background-repeat: repeat-y; |
| bg-repeat-space | background-repeat: space; |
| bg-repeat-round | background-repeat: round; |
| bg-no-repeat | background-repeat: no-repeat; |
Reach for the bg-repeat utility when you want the background image tiled across both the vertical and horizontal axes.
<div class="bg-[url(/img/clouds.svg)] bg-center bg-repeat ..."></div>Reach for the bg-repeat-x utility when the background image should tile only along the horizontal axis.
<div class="bg-[url(/img/clouds.svg)] bg-center bg-repeat-x ..."></div>Reach for the bg-repeat-y utility when the background image should tile only along the vertical axis:
<div class="bg-[url(/img/clouds.svg)] bg-center bg-repeat-y ..."></div>Reach for the bg-repeat-space utility so the background image tiles neatly without any clipping:
<div class="bg-[url(/img/clouds.svg)] bg-center bg-repeat-space ..."></div>Reach for the bg-repeat-round utility to tile the background image without clipping, stretching each tile as needed so no gaps appear:
<div class="bg-[url(/img/clouds.svg)] bg-center bg-repeat-round ..."></div>Reach for the bg-no-repeat utility to stop a background image from tiling altogether:
<div class="bg-[url(/img/clouds.svg)] bg-center bg-no-repeat ..."></div>Pair a background-repeat utility with a breakpoint variant such as md: so the rule kicks in only from medium-width screens on upward:
<div class="bg-repeat md:bg-repeat-x ..."> <!-- ... --></div>Dig deeper into how variants work over in variants documentation.