Prefix utilities with interaction states: hover:bg-indigo-700, active:scale-95, disabled:opacity-50, group-hover:text-indigo-600. Tailwind generates pseudo-class rules so you avoid handwritten :hover blocks.
Group and peer patterns
groupon parent +group-hover:on child — card lifts when anywhere on card is hoveredpeeron input +peer-invalid:on error text — sibling styling without JS
See also Utility CSS state variants for the underlying CSS concept.
Important interview questions and answers
- Q: How does group-hover work?
A: Parent getsgroup; children usegroup-hover:utilities that activate when the parent matches :hover. - Q: Why not inline onmouseover?
A: Variant utilities keep behavior in CSS, respect design tokens, and avoid mixing JS presentation hacks.
Self-check
- When would you use peer over group?
- Name two state prefixes besides hover.
Challenge
Hover and active
- Add
hover:bg-indigo-700 active:scale-95to a button. - Tab to it and confirm focus-visible styles still show.
Done when: hover, active, and keyboard focus are all distinguishable.