Tailwind CSS Background Repeat

The bg-{repeat} utility class in Tailwind CSS allows you to control the repetition behavior of background images applied to elements. With Tailwind background repeat class, you can easily adjust how background images are repeated to achieve the desired visual effect.

Applying Tailwind Background Repeat

To apply a specific tailwind background repeat behavior to an element, you can use the bg-{repeat} utility class, where {repeat} represents the desired background repeat behavior. Here are some common values you can use:

  • bg-repeat: The background image is repeated both horizontally and vertically.
  • bg-no-repeat: The background image is not repeated, appearing only once.
  • bg-repeat-x: The background image is repeated horizontally but not vertically.
  • bg-repeat-y: The background image is repeated vertically but not horizontally. Here's an example:
html
<div class="bg-repeat">
This element has a background image that is repeated both horizontally and vertically.
</div>

Preview

Responsive Tailwind Background Repeat

Tailwind CSS allows you to apply background repeat classes responsively at different breakpoints. To use responsive tailwind background repeat classes, you can append the breakpoint prefix to the utility class. For example, md:bg-no-repeat sets the background to not repeat starting from the medium breakpoint and above.

html
<div class="bg-no-repeat md:bg-repeat">
This element has a background image that doesn't repeat by default, but starting from the medium
breakpoint and above, it repeats both horizontally and vertically.
</div>

In the above example, the tailwind background repeat behavior of the <div> element is set to not repeat by default (bg-no-repeat), but starting from the medium breakpoint and above, it changes to repeat both horizontally and vertically (md:bg-repeat).

Tailwind Background Repeat Class Table

ClassProperties
bg-repeatbackground-repeat: repeat;
bg-no-repeatbackground-repeat: no-repeat;
bg-repeat-xbackground-repeat: repeat-x;
bg-repeat-ybackground-repeat: repeat-y;
bg-repeat-roundbackground-repeat: round;
bg-repeat-spacebackground-repeat: space;

Windframe Tailwind blocks

Timeline

Build modern projects using Bootstrap 5 and Contrast

Trying to create components and pages for a web app or website from scratch while maintaining a modern User interface can be very tedious. This is why we created Contrast, to help drastically reduce the amount of time we spend doing that. so we can focus on building some other aspects of the project.

Contrast Bootstrap PRO consists of a Premium UI Kit Library featuring over 10000+ component variants. Which even comes bundled together with its own admin template comprising of 5 admin dashboards and 23+ additional admin and multipurpose pages for building almost any type of website or web app.
See a demo and learn more about Contrast Bootstrap Pro by clicking here.

ad-banner