Tailwind CSS Hover
Tailwind CSS provides utility classes for handling hover states on elements. These classes follow a convention of using the hover: prefix to apply styles when the element is hovered over.
Syntax
The Tailwind CSS Hover plugin adds hover-specific utilities to elements. The syntax for using the hover plugin is as follows:
<!-- on hover -->
<div class="hover:bg-gray-200"></div>
<!-- on focus and hover -->
<button class="focus:hover:bg-blue-500"></button>
<!-- on hover when parent is focused -->
<span class="focus-within:hover:bg-green-500"></span>
Examples
Here are some examples of using Tailwind CSS Hover:
Example 1
<!-- Button with hover background color -->
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Hover me!
</button>