Skip to main content

Background Color

Set the background color for an element.

View as Markdown
baselinewidely

Variants

Prefix any class with a variant to apply it only under that condition. Variants stack, as in @md:h:bg:indigo-8.

Breakpoints

Apply a class from a viewport width up. Each breakpoint covers its width & every width above it.

@xs:bg:indigo-8From 32rem up.
@sm:bg:indigo-8From 40rem up.
@md:bg:indigo-8From 48rem up.
@lg:bg:indigo-8From 64rem up.
@xl:bg:indigo-8From 80rem up.
@xxl:bg:indigo-8From 96rem up.

Containers

Apply a class from a container's width up, not the viewport's. Mark the parent with ct:is first.

@c:xs:bg:indigo-8Container from 32rem up.
@c:sm:bg:indigo-8Container from 40rem up.
@c:md:bg:indigo-8Container from 48rem up.
@c:lg:bg:indigo-8Container from 64rem up.
@c:xl:bg:indigo-8Container from 80rem up.
@c:xxl:bg:indigo-8Container from 96rem up.

Media

Apply a class when the device or the page matches a condition, or on the first frame an element renders.

@pc:bg:indigo-8On a touch screen.
@prm:bg:indigo-8With reduced motion on.
@st:bg:indigo-8On the first frame.

States

Apply a class only while the element is in a state, such as hovered, focused or checked.

h:bg:indigo-8On :hover.
f:bg:indigo-8On :focus.
fv:bg:indigo-8On :focus-visible.
a:bg:indigo-8On :active.
d:bg:indigo-8On :disabled.
fc:bg:indigo-8On :first-child.
c:bg:indigo-8On :checked.
e:bg:indigo-8On :empty.
fw:bg:indigo-8On :focus-within.
i:bg:indigo-8On :invalid.
in:bg:indigo-8On :indeterminate.
lc:bg:indigo-8On :last-child.
nc:bg:indigo-8On :nth-child.
r:bg:indigo-8On :required.
ro:bg:indigo-8On :read-only.
v:bg:indigo-8On :valid.

Pseudo Elements

Style a part of the element rather than the element itself, such as its placeholder or the selected text.

a::bg:indigo-8On ::after.
b::bg:indigo-8On ::before.
p::bg:indigo-8On ::placeholder.
s::bg:indigo-8On ::selection.

Opacity

Add a slash & a step after a color to set its opacity.

bg:indigo-8/50At 50% opacity, in steps of 5.