Tailwind CSS interview question · Most asked

How do variants like hover:, focus-visible:, group- and peer- work?

Create a free account to save this page, take notes and track your progress. Sign in

Summary

Variants apply a utility only in a state: hover:bg-sky-600. group marks a parent so children react to its state (group-hover:); peer marks an element so later siblings react to it (peer-checked:, peer-invalid:). has-* styles a parent based on its children. Variants stack: md:hover:bg-sky-600.

Longer Answer

Use focus-visible: for keyboard focus rings; aria-* and data-* variants style from ARIA and data attributes.

Key Points

  • State variants.
  • group for parents.
  • peer for siblings.
  • has for children; variants stack.

Deep dive: Tailwind CSS Tutorial: Group, Peer and Has

Explanation

What interviewers look for

group vs peer explained correctly.

More most-asked Tailwind CSS questions

← All Tailwind CSS questions

Was this page helpful?