MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
State Variants: Hover, Focus, Active, Disabled & Group-Hover0%
Study Materials
Tailwind CSSProgress 0%
1.1Why Tailwind CSS? Utility-First vs Traditional Semantic CSS1.2Installation via PostCSS, Vite & Next.js Framework Integration1.3Tailwind Core Spacing, Sizing, Padding & Margin Scales1.4Typography: Font Families, Sizes, Weights, Leading & Tracking
3.1State Variants: Hover, Focus, Active, Disabled & Group-Hover3.2Class-Based Dark Mode Setup with System Preference Support3.3Transitions, Smooth Transforms, Scale & Custom Keyframe Animations3.4Component Extraction, @apply Directives & Tailwind Merge (clsx)3.5Tailwind Config Customization: Colors, Fonts & Official Plugins
HomeTutorialsTailwind CSSState Variants: Hover, Focus, Active, Disabled & Group-Hover
Class-Based Dark Mode Setup with System Preference Support

State Variants: Hover, Focus, Active, Disabled & Group-Hover

Beginner12 min read•Updated: 2026-11-18•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

Dynamic web applications require rich visual feedback when users interact with elements. Tailwind CSS handles pseudo-classes—such as :hover, :focus, :active, :disabled, and :focus-visible—using prefix modifiers. Furthermore, features like group-hover and peer-focus enable complex parent-child and sibling interaction patterns.


1. Core State Modifiers

1<!-- Interactive Button with Hover, Focus & Active States -->
2<button class="
3 px-5 py-2.5 rounded-xl font-bold text-white
4 bg-blue-600 hover:bg-blue-700
5 focus:outline-none focus:ring-4 focus:ring-blue-300
6 active:scale-95 transition-all
7 disabled:opacity-50 disabled:cursor-not-allowed
8">
9 Submit Application
10</button>
  • hover:: Triggered when mouse cursor hovers over the element.
  • focus: / focus-visible:: Triggered when element receives keyboard or click focus.
  • active:: Triggered when mouse is clicked down on the element.
  • disabled:: Triggered when button/input has disabled attribute.

2. Parent-Triggered Interactions with group-hover

Often, you want hovering over an entire card to animate an internal icon or change title colors. Mark the parent with group and the child with group-hover::

1<!-- Course Card with group-hover -->
2<div class="group p-6 bg-white rounded-2xl border border-slate-200 hover:border-blue-500 hover:shadow-xl transition-all cursor-pointer">
3 <div class="flex items-center justify-between">
4 <span class="text-xs font-bold text-blue-600 bg-blue-50 px-2.5 py-1 rounded-md">New</span>
5
6 <!-- Arrow slides to the right when parent CARD is hovered! -->
7 <svg class="w-5 h-5 text-slate-400 group-hover:text-blue-600 group-hover:translate-x-1 transition-transform" fill="none" stroke="currentColor" viewBox="0 0 24 24">
8 <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3"/>
9 </svg>
10 </div>
11
12 <h3 class="mt-4 text-lg font-bold text-slate-900 group-hover:text-blue-600 transition-colors">
13 Full-Stack MERN Mastery
14 </h3>
15</div>

3. Sibling-Triggered Interactions with peer

To style an element based on the state of a sibling element (e.g., floating form labels), mark the input with peer and sibling with peer-focus::

1<div class="relative">
2 <input type="email" id="email" placeholder=" "
3 class="peer w-full px-4 py-3 border rounded-xl focus:border-blue-600 focus:outline-none" />
4 <label for="email"
5 class="absolute left-4 top-3 text-slate-400 pointer-events-none transition-all
6 peer-placeholder-shown:top-3 peer-placeholder-shown:text-base
7 peer-focus:-top-2.5 peer-focus:text-xs peer-focus:text-blue-600 peer-focus:bg-white peer-focus:px-1">
8 Email Address
9 </label>
10</div>

Interactive Quiz• Knowledge Check

Multiple Choice Questions

Question 1
In Tailwind CSS, how do you style a child icon to rotate 45 degrees whenever its parent card container is hovered?
Question 2
Which modifier ensures focus outline rings only appear when navigating via keyboard (avoiding ugly rings on mouse clicks)?
Question 3
How do you disable mouse events and reduce opacity on a disabled button in Tailwind?
Question 4
What does the peer modifier allow developers to accomplish?
Question 5
What is the effect of active:scale-95 on a button?

Next Lesson

Class-Based Dark Mode Setup with System Preference Support

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Positioning, Z-Index, Floats, Overflows & Aspect Ratio UtilitiesClass-Based Dark Mode Setup with System Preference Support

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master Tailwind CSS with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext