Open In App

How to Apply Inset to Box Shadow in Tailwind CSS?

Last Updated : 23 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In web development, shadows play a significant role in attracting user attention. By applying shadows to elements on our web pages, we can enhance their visual appearance and attract the user's focus. In Tailwind CSS, we can apply an insert box shadow by using the "shadow-inner" utility class.

Approach

  • First, create a basic HTML structure and include the Tailwind CSS CDN link in your file.
  • Then use Tailwind CSS's "grid" utility class to create a layout with two columns. Add some spacing between the grid items using the "gap" utility class.
  • Inside the grid layout, add some "div" elements with different background colors using Tailwind's utility classes. And also use "w-64" and "h-64" for width and height, and "flex" to center the content.
  • To show the shadow on hover, use Tailwind's hover: prefix. The "hover:shadow-2xl" class adds a large shadow when the user hovers over the div.

Example: A responsive web page showcasing a grid of colorful, hover-animated boxes with shadows using Tailwind CSS.

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, 
                   initial-scale=1.0">
    <title>Hover Box Shadow</title>
    <script src="https://cdn.tailwindcss.com/3.4.16">

    </script>
</head>

<body class="flex items-center
 justify-center min-h-screen
  bg-gray-100">
    <div class="grid grid-cols-2 gap-8">
        <div class="w-64 h-64 
    bg-blue-400 flex items-center 
    justify-center text-white 
    font-semibold rounded-lg 
    hover:shadow-2xl transition-shadow 
    duration-300">
            Hover Me!
        </div>
        <div class="w-64 h-64
     bg-green-400 flex
      items-center justify-center 
      text-white font-semibold 
      rounded-lg hover:shadow-2xl 
      transition-shadow duration-300">
            Hover Me!
        </div>
        <div class="w-64 h-64 
    bg-pink-400 flex 
    items-center justify-center
     text-white font-semibold
      rounded-lg hover:shadow-2xl 
      ctransition-shadow duration-300">
            Hover Me!
        </div>
        <div class="w-64 h-64 
    bg-purple-400 flex 
    items-center justify-center
     text-white font-semibold 
     rounded-lg hover:shadow-2xl
      transition-shadow duration-300">
            Hover Me!
        </div>
    </div>
</body>

</html>

Output:


Article Tags :

Similar Reads