Tailwind CSS Hover Effects Last Updated : 03 Sep, 2024 Comments Improve Suggest changes Like Article Like Report A hover effect is a visual change that occurs when a user moves their mouse pointer over an element on a webpage. We can achieve a hover effect by Tailwind CSS built-in prefix modifier called "hover: ".These are the following ways to use hover:Table of ContentSimple Hover Effect (Background color change)Scale on HoverShadow Effect on Hover (Card Shadow)Simple Hover Effect (Background color change)First, create a basic HTML structure.Then include the Tailwind CSS CDN link in the <head> section to apply Tailwind CSS classes.Inside the <body>, add a button element and apply Tailwind classes for styling (e.g., bg-blue-500, text-white, py-2, px-4, rounded).For the hover effect use the "hover:bg-blue-700" class to change the background color on hover.Example: This example shows the implementation of above explained approach HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content= "width=device-width, initial-scale=1.0"> <title>Simple Hover Effect</title> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="flex flex-col items-center justify-center h-screen bg-gray-100"> <h1 class="text-2xl font-bold mb-6 text-green-600"> Simple Hover Effect </h1> <button class="bg-blue-500 text-white font-bold py-2 px-4 rounded hover:bg-blue-700 hover:text-gray-200"> Hover me </button> </body> </html> Output:Scale on HoverFirst, create a basic HTML structure for your need.Then include the Tailwind CSS CDN link in the <head> section to apply Tailwind CSS classes.And inside the <body>, add a button element and apply Tailwind classes for styling (e.g., bg-blue-500, text-white, py-2, px-4, rounded).Use the "transform" class to allow transformations, and use "hover:scale-105" for scaling the button on hover. Include transition, duration-300, and ease-in-out for smooth animation.Example: This example shows the implementation of above explain approach HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content= "width=device-width, initial-scale=1.0"> <title>Scale on Hover</title> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="flex flex-col items-center justify-center h-screen bg-gray-100"> <h1 class="text-2xl font-bold mb-6 text-green-600"> Scale on Hover Effect </h1> <button class="bg-green-500 text-white font-bold py-2 px-4 rounded transform hover:scale-105 transition duration-300 ease-in-out"> Hover me </button> </body> </html> Output:Shadow Effect on Hover (Card Shadow)First, create a basic HTML structure for your need.Then include the Tailwind CSS CDN link in the <head> section to apply Tailwind CSS classes.And inside the <body>, create a card using a div with the "max-w-sm", "rounded", "overflow-hidden", and "shadow-lg classes". Also add an image and text content inside the card for attract user attention.Then use the "hover:shadow-2xl" class to increase the shadow intensity on hover.Example: This example shows the implementation of above explain approach HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content= "width=device-width, initial-scale=1.0"> <title>Shadow Effect on Hover</title> <script src= "https://cdn.tailwindcss.com"></script> </head> <body class="flex flex-col items-center justify-center h-screen bg-gray-100"> <h1 class="text-2xl font-bold mb-6 text-green-600"> Hover Shadow Effect on Card </h1> <div class="max-w-sm rounded overflow-hidden shadow-lg hover:shadow-2xl transition duration-300 ease-in-out"> <img class="w-full" src= "https://media.geeksforgeeks.org/wp-content/uploads/20230602174859/OpenAI-Python-Tutorial-.webp" alt="Sample Image"> <div class="px-6 py-4"> <div class="font-bold text-xl mb-2"> Card Title </div> <p class="text-green-600 text-base"> This is a sample card with hover shadow effect. Hover over the card to see the effect. </p> </div> </div> </body> </html> Output: Comment More infoAdvertise with us Next Article Tailwind CSS Hover Effects skaftafh Follow Improve Article Tags : Tailwind CSS Similar Reads Tailwind CSS Pointer Events This class accepts lots of value in tailwind CSS in which all the properties are covered in class form. This class is used to specify whether elements show to pointer events or not show on the pointer. In CSS, we do that by using the CSS pointer-events property. Pointer Events Classes: pointer-event 1 min read Tailwind CSS Cursor Tailwind CSS offers various utility classes to set the mouse cursor appearance when pointing at an element. These classes correspond to the CSS cursor property, allowing you to quickly specify the cursor type without writing custom CSS Cursor Classes:ClassDescriptioncursor-autoDefault cursor set by 2 min read Tailwind CSS Filter The filter class is used to set the visual effect of an element. This class is mostly used in image content. In CSS, we do that by using the CSS filter property. Tailwind CSS newly added feature filter in 2.1 version. Filter Classes: filter: This class is used to enable filters.filter-none: This cla 1 min read How to Modify Hover Effect using Tailwind CSS ? In Tailwind CSS, the term "modify hover" refers to changing the styles that are applied to an element when it is hovered over. With Tailwind CSS "hover" variation, you can quickly apply particular utility classes and custom classes to control how components appear when you hover over them, giving yo 3 min read CSS Text Effects CSS (Cascading Style Sheets) is the mechanism used to add style to web documents. Through CSS, we can apply various effects on text, enhancing its appearance and improving user experience on web pages.In this article, we'll cover several key CSS properties that can be used to apply text effects, inc 4 min read Underline Hover Animation Effect using Tailwind CSS The Tailwind CSS underline animation is a visual effect that can be added to any text or heading or a specific word in the web page using the Tailwind CSS utility framework. The basic function of this effect is this creates an underline animation from left to right with a smooth transition, in simpl 3 min read Tailwind CSS Opacity This class accepts lots of value in tailwind CSS in which all the properties are covered in class form. By using this class we can set the opacity of any element. In CSS, we do that by using the CSS Opacity property. Opacity class: opacity-0: Control the opacity of an element. Note: The number of th 1 min read Tailwind CSS Box Shadow This class accepts lots of value in tailwind CSS in which all the properties are covered in class form. By using this class we can control the box-shadow of an element. In CSS, we do that by using the CSS Shadow Effect properties of box-shadow. Box Shadow classes:shadow-sm: This class is used to cre 2 min read Tailwind CSS Drop Shadow The Drop Shadow class is used to apply a filter to the image to set the shadow of the image. This class creates a blurred shadow in a given offset and color. In CSS, we do that by using the CSS drop-shadow() Function. Tailwind CSS newly added feature brightness in 2.1 version. Drop Shadow: drop-shad 1 min read Tailwind CSS Text Decoration This class accepts more than one value in tailwind CSS. All the properties are covered in class form. It is the alternative to the CSS text-decoration property. This class is used to âdecorateâ the content of the text. It is essentially decorating the text with different kinds of lines. Text Decorat 2 min read Like