tailwind-css
  1. tailwind-css-drop-shadow

Tailwind CSS Drop Shadow

In Tailwind CSS, the drop-shadow utility class is used to add drop shadow effects to an element.

Syntax

The drop-shadow utility class can be added to any HTML element in the following way:

<div class="drop-shadow"></div>

This adds a default drop shadow of 1px to the element.

You can also customize the drop-shadow property using the following syntax:

<div class="drop-shadow {x-offset} {y-offset} {blur} {spread} {color}"></div>

Where:

  • {x-offset} is the horizontal offset of the shadow. This can be a negative value to move the shadow to the left.
  • {y-offset} is the vertical offset of the shadow. This can be a negative value to move the shadow upwards.
  • {blur} is the amount of blur to apply to the shadow.
  • {spread} is the amount of spread to apply to the shadow.
  • {color} is the color of the shadow.

Example

<div class="w-64 h-64 bg-blue-500 drop-shadow-2xl"></div>

Output

The above code will produce a blue-colored square element with a drop shadow effect applied to it.

Explanation

In the above example, we have used the w-64 and h-64 classes to set the width and height of the element, respectively. We have also used the bg-blue-500 class to set the background color of the element.

drop-shadow-2xl class adds a 2xl sized drop shadow effect to the element. We can customize the drop-shadow property using different values of {x-offset}, {y-offset}, {blur}, {spread}, and {color} as per our requirements.

Use

The drop-shadow utility class can be used to add depth and dimension to your website's design. You can use it to add subtle or bold shadow effects to text, buttons, containers, and more.

Important Points

  • By default, drop-shadow utility class adds a 1px drop shadow effect to an element.
  • You can customize the drop-shadow property using different values of {x-offset}, {y-offset}, {blur}, {spread}, and {color}.
  • You can also customize the size of the drop shadow effect using Tailwind's breakpoint classes such as sm, md, lg, etc. and their variants.

Summary

In this guide, we have learned about the drop-shadow utility class in Tailwind CSS. We have discussed its syntax, example, output, explanation, use, important points, and summarized it to help you get started with adding drop shadow effects to your website's design.

Published on: