Overview - Arbitrary variants for custom selectors
What is it?
Arbitrary variants in Tailwind CSS let you create custom styles that apply only when specific conditions or selectors match. Instead of using only the built-in variants like hover or focus, you can write your own CSS selectors inside square brackets to target unique states or elements. This helps you style parts of your page in ways Tailwind doesn't cover by default.
Why it matters
Without arbitrary variants, you are limited to the predefined states Tailwind offers, which can make styling complex or unique UI interactions hard or impossible. Arbitrary variants solve this by letting you write any CSS selector you want, giving you full control and flexibility. This means you can build richer, more interactive designs without leaving Tailwind's utility-first approach.
Where it fits
Before learning arbitrary variants, you should understand basic Tailwind utilities and how variants like hover, focus, and responsive prefixes work. After mastering arbitrary variants, you can explore advanced Tailwind features like plugin creation or combining variants for complex UI states.