Problem: Radio cards.
Solution#
<fieldset class="grid gap-4 sm:grid-cols-3">
<label class="has-[:checked]:border-blue-600 has-[:checked]:ring-2 has-[:checked]:ring-blue-100 cursor-pointer rounded-xl border p-4">
<input type="radio" name="plan" class="sr-only" />
<span class="font-semibold">Pro</span>
</label>
</fieldset>Why this works#
has-[:checked] styles the selected card — zero JS.
Variants#
- Responsive: add screen prefixes to the core classes
- Dark: pair each color utility with its dark: twin
- Animated: add
transition+ a state variant for motion
Related recipes#
cookbook/index|Cookbook index · utilities/index|Utilities reference · patterns/index|Layout patterns
