Skip to content

Background Utilities

The background utilities provide a set of classes to adjust the bg-attachment, bg-clip, bg-image, bg-origin, bg-position, bg-repeat, and bg-size properties of elements.

✏️ Note

For background-color utility classes, please refer to the color utilities.

Background Attachment

Class NamePropertyValue
.bg-attachment-scrollbackground-attachmentscroll
.bg-attachment-fixedbackground-attachmentfixed
.bg-attachment-localbackground-attachmentlocal

.bg-attachment-scroll

Sets the background-attachment property to scroll.

.bg-attachment-fixed

Sets the background-attachment property to fixed.

.bg-attachment-local

Sets the background-attachment property to local.

Background Clip

Class NamePropertyValue
.bg-clip-border-boxbackground-clipborder-box
.bg-clip-padding-boxbackground-clippadding-box
.bg-clip-content-boxbackground-clipcontent-box
.bg-clip-textbackground-cliptext

.bg-clip-border-box

Sets the background-clip property to border-box.

.bg-clip-padding-box

Sets the background-clip property to padding-box.

.bg-clip-content-box

Sets the background-clip property to content-box.

.bg-clip-text

Sets the background-clip property to text.

Background Image

Class NamePropertyValue
.bg-image-nonebackground-imagenone

.bg-image-none

Sets the background-image property to none.

Background Position

Class NamePropertyValue
.bg-position-topbackground-positiontop
.bg-position-rightbackground-positionright
.bg-position-bottombackground-positionbottom
.bg-position-leftbackground-positionleft
.bg-position-centerbackground-positioncenter

.bg-position-top

Sets the background-position property to top.

.bg-position-right

Sets the background-position property to right.

.bg-position-bottom

Sets the background-position property to bottom.

.bg-position-left

Sets the background-position property to left.

.bg-position-center

Sets the background-position property to center.

Background Repeat

Class NamePropertyValue
.bg-repeat-repeatbackground-repeatrepeat
.bg-repeat-repeat-xbackground-repeatrepeat-x
.bg-repeat-repeat-ybackground-repeatrepeat-y
.bg-repeat-spacebackground-repeatspace
.bg-repeat-roundbackground-repeatround
.bg-repeat-no-repeatbackground-repeatno-repeat

.bg-repeat-repeat

Sets the background-repeat property to repeat.

.bg-repeat-repeat-x

Sets the background-repeat property to repeat-x.

.bg-repeat-repeat-y

Sets the background-repeat property to repeat-y.

.bg-repeat-space

Sets the background-repeat property to space.

.bg-repeat-round

Sets the background-repeat property to round.

.bg-repeat-no-repeat

Sets the background-repeat property to no-repeat.

Background Size

Class NamePropertyValue
.bg-size-autobackground-sizeauto
.bg-size-coverbackground-sizecover
.bg-size-containbackground-sizecontain

.bg-size-auto

Sets the background-size property to auto.

.bg-size-cover

Sets the background-size property to cover.

.bg-size-contain

Sets the background-size property to contain.

Customization

To customize the background utilities, you can use the following variables.

VariableDefault ValueDescription
$selector-base"."The base selector for the utility classes.
$use-importanttrueA flag to determine if the !important flag should be added to the utility classes.
$screen-awarefalseA flag to generate screen-aware utility classes.
$theme-awarefalseA flag to generate theme-aware utility classes.
$state-awarefalseA flag to generate state-aware utility classes.
$screen-aware-separator":"The separator for screen-aware utility classes.
$theme-aware-separator":"The separator for theme-aware utility classes.
$state-aware-separator":"The separator for state-aware utility classes.
$background-attachment-selector-prefix"bg-attachment-"The prefix for the background attachment utility classes.
$custom-background-attachment-properties()The custom properties and values for the background attachment utility classes.
$background-clip-selector-prefix"bg-clip-"The prefix for the background clip utility classes.
$custom-background-clip-properties()The custom properties and values for the background clip utility classes.
$background-image-selector-prefix"bg-image-"The prefix for the background image utility classes.
$custom-background-image-properties()The custom properties and values for the background image utility classes.
$background-origin-selector-prefix"bg-origin-"The prefix for the background origin utility classes.
$custom-background-origin-properties()The custom properties and values for the background origin utility classes.
$background-position-selector-prefix"bg-position-"The prefix for the background position utility classes.
$custom-background-position-properties()The custom properties and values for the background position utility classes.
$background-repeat-selector-prefix"bg-repeat-"The prefix for the background repeat utility classes.
$custom-background-repeat-properties()The custom properties and values for the background repeat utility classes.
$background-size-selector-prefix"bg-size-"The prefix for the background size utility classes.
$custom-background-size-properties()The custom properties and values for the background size utility classes.

Responsive variants

To generate responsive alignment utilities, you can set the $screen-aware, $theme-aware, or $state-aware variables to true.

By default, no responsive alignment utilities are generated.

✏️ Note

For more information on responsive variants, refer to the Responsive utility classes documentation.