Nearby lessons

7 of 61

🎭 Tailwind CSS - Hover, Focus, and Other States

📖 State Variants Overview

State variants in Tailwind CSS allow you to apply utility classes conditionally based on the state of an element. This includes hover, focus, active, disabled, and many other states.

State variants use the format state:utility where state can be hover, focus, active, disabled, and utility is any Tailwind utility class.

🖱️ Hover State

The hover state applies styles when the user hovers over an element. This is commonly used for buttons, links, and interactive elements.

🌀

tailwind Designer

Live Component Playground

html Source
Loading...
Built with Tailwind CSS • Instant Reflection

🎯 Focus State

The focus state applies styles when an element has focus. This is crucial for accessibility and is commonly used with form elements and interactive components.

🌀

tailwind Designer

Live Component Playground

html Source
Loading...
Built with Tailwind CSS • Instant Reflection

🔘 Active State

The active state applies styles when an element is being activated (clicked). This provides visual feedback during user interaction.

🌀

tailwind Designer

Live Component Playground

html Source
Loading...
Built with Tailwind CSS • Instant Reflection

🚫 Disabled State

The disabled state applies styles to disabled form elements. This helps communicate that an element is not interactive.

🌀

tailwind Designer

Live Component Playground

html Source
Loading...
Built with Tailwind CSS • Instant Reflection

📱 Responsive States

Combine state variants with responsive prefixes to create different behaviors on different screen sizes.

🌀

tailwind Designer

Live Component Playground

html Source
Loading...
Built with Tailwind CSS • Instant Reflection

🎨 Group Hover

The group-hover variant allows you to style child elements when the parent element is hovered. This is useful for card components and complex interactions.

🌀

tailwind Designer

Live Component Playground

html Source
Loading...
Built with Tailwind CSS • Instant Reflection

🔗 Focus Within

The focus-within variant applies styles to a parent element when any child element has focus. This is useful for form containers.

🌀

tailwind Designer

Live Component Playground

html Source
Loading...
Built with Tailwind CSS • Instant Reflection

📂 Required and Invalid States

Tailwind provides states for form validation including required and invalid states. These help with form UX and validation feedback.

🌀

tailwind Designer

Live Component Playground

html Source
Loading...
Built with Tailwind CSS • Instant Reflection

🎭 Checked and Indeterminate States

Use checked and indeterminate states for checkboxes and radio buttons to provide visual feedback for selection states.

🌀

tailwind Designer

Live Component Playground

html Source
Loading...
Built with Tailwind CSS • Instant Reflection

🔄 Motion Reduce

The motion-reduce variant respects user preferences for reduced motion. This is important for accessibility and users with vestibular disorders.

🌀

tailwind Designer

Live Component Playground

html Source
Loading...
Built with Tailwind CSS • Instant Reflection

🔧 Combining Multiple States

You can combine multiple state variants to create complex interactions. Stack state prefixes for sophisticated behaviors.

🌀

tailwind Designer

Live Component Playground

html Source
Loading...
Built with Tailwind CSS • Instant Reflection

🧠 Test Your Knowledge

5 Questions

Progress: 0 / 5
Keep Going!Tailwind CSS - Responsive Design