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