Dev Helpers

Tailwind CSS / Adaptive controls

Selection background swatch

Dev Helpers · December 2, 2026

The selection variant lets a component specify its own selected-text colours. Readability depends on the selected foreground as well as the highlight.

Worked example

<p class="demo selection:bg-amber-200 selection:text-gray-900">
  Select this sentence to see the proof colour.
</p>

Implementation notes

Global selection styles and local variants can disagree. Inspect a selection that begins in the component and ends in surrounding prose.

Try it yourself

Select the label on both light and dark backgrounds.

Open the Tailwind CSS example →

Editorial date December 2, 2026 · Published December 6, 2026

Related articles

Skew a label

A skew utility changes the painted shape without allocating extra room for the slanted edge. A separate inner wrapper can keep lettering upright.

Horizontal flex row

Flex utilities define the row but children can still resist shrinking. Inspect long labels before adding more breakpoints.

Perforated tear line

A perforated divider can use an arbitrary background value when a standard border lacks the desired spacing. Keep the pattern in one reusable class list.