Drop shadows add depth and make shapes stand out. They help users see elements clearly, even if the shape is not a simple square or circle.
Drop shadow on irregular shapes in Tailwind
Start learning this pattern below
Jump into concepts and practice - no test required
<div class="shadow-[drop-shadow(4px_4px_6px_rgba(0,0,0,0.4))]">Your content</div>Use shadow-[drop-shadow(...)] to apply custom drop shadows in Tailwind.
Inside the parentheses, write the CSS drop-shadow values: offset-x, offset-y, blur-radius, and color.
<div class="shadow-[drop-shadow(5px_5px_5px_rgba(0,0,0,0.5))] rounded-full bg-blue-400 w-24 h-24"></div><div class="shadow-[drop-shadow(3px_3px_4px_rgba(0,0,0,0.3))] bg-pink-300 w-32 h-20 clip-path-[polygon(50%_0%,_100%_50%,_50%_100%,_0%_50%)]"></div><div class="shadow-[drop-shadow(2px_2px_3px_rgba(0,0,0,0.6))] bg-green-500 w-40 h-24 rounded-[30%_70%_70%_30%_/_30%_30%_70%_70%]"></div>This page shows three shapes with drop shadows using Tailwind's custom shadow syntax. The first is a circle, the second is a diamond shape using a polygon clip path, and the third is an irregular polygon shape. Each shape has a shadow that follows its outline, making them stand out on the light background.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Drop Shadow on Irregular Shapes</title> <script src="https://cdn.tailwindcss.com"></script> <style> .clip-diamond { clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); } .clip-irregular { clip-path: polygon(30% 0%, 70% 10%, 90% 50%, 70% 90%, 30% 100%, 10% 50%); } </style> </head> <body class="flex flex-col items-center justify-center min-h-screen gap-12 bg-gray-100 p-6"> <h1 class="text-2xl font-semibold mb-4">Drop Shadow on Irregular Shapes</h1> <div class="shadow-[drop-shadow(6px_6px_8px_rgba(0,0,0,0.4))] bg-purple-500 w-32 h-32 rounded-full"></div> <div class="shadow-[drop-shadow(4px_4px_6px_rgba(0,0,0,0.35))] bg-pink-400 w-40 h-40 clip-diamond"></div> <div class="shadow-[drop-shadow(5px_5px_7px_rgba(0,0,0,0.5))] bg-green-600 w-48 h-48 clip-irregular"></div> </body> </html>
Use clip-path CSS to create irregular shapes that shadows can follow.
Tailwind's shadow-[drop-shadow(...)] allows custom shadows beyond the default presets.
Test shadows on different backgrounds to ensure good contrast and visibility.
Drop shadows add depth and help shapes stand out visually.
Use Tailwind's custom shadow-[drop-shadow(...)] syntax for irregular shapes.
Combine with clip-path to create and shadow any shape you want.
Practice
Solution
Step 1: Understand drop shadow effect
Drop shadows create a shadow behind an element, giving it a sense of depth.Step 2: Apply to irregular shapes
Using drop shadows on irregular shapes helps them visually pop from the background.Final Answer:
To add depth and make the shape stand out visually -> Option AQuick Check:
Drop shadow purpose = add depth [OK]
- Thinking drop shadows change color
- Confusing drop shadows with resizing
- Assuming drop shadows remove borders
Solution
Step 1: Recognize Tailwind custom shadow syntax
Tailwind uses square brackets for custom CSS values, e.g., shadow-[drop-shadow(...)]Step 2: Match the correct CSS drop-shadow format
The correct CSS function is drop-shadow(offsetX offsetY blurRadius color), here 3px 3px 5px rgba(0,0,0,0.5)Final Answer:
shadow-[drop-shadow(3px_3px_5px_rgba(0,0,0,0.5))] -> Option DQuick Check:
Custom drop shadow syntax = shadow-[drop-shadow(...)] [OK]
- Missing square brackets for custom values
- Using invalid class names without brackets
- Confusing drop-shadow with shadow utilities
<div class="w-40 h-40 bg-blue-500 clip-path-[polygon(50%_0%,100%_50%,50%_100%,0%_50%)] shadow-[drop-shadow(4px_4px_6px_rgba(0,0,0,0.4))]"></div>
What will you see rendered in the browser?
Solution
Step 1: Analyze clip-path polygon points
The polygon points create a diamond shape by connecting top, right, bottom, and left midpoints.Step 2: Understand drop shadow parameters
The drop shadow is offset 4px right and 4px down with a 6px blur and semi-transparent black color, creating a soft shadow bottom-right.Final Answer:
A blue diamond shape with a soft shadow offset to bottom-right -> Option BQuick Check:
clip-path diamond + drop shadow offset = diamond with shadow [OK]
- Ignoring clip-path shape and expecting a square
- Confusing shadow offset direction
- Assuming circle shape from polygon
shadow-[drop-shadow(5px 5px 10px rgba(0,0,0,0.3))]But the shadow does not appear. What is the likely issue?
Solution
Step 1: Check Tailwind custom class syntax
Tailwind requires no spaces inside square brackets for custom values; spaces must be replaced with underscores.Step 2: Confirm correct syntax for drop-shadow
Correct syntax is shadow-[drop-shadow(5px_5px_10px_rgba(0,0,0,0.3))] with underscores instead of spaces.Final Answer:
Spaces inside square brackets should be replaced with underscores -> Option AQuick Check:
Custom class spaces = underscores [OK]
- Leaving spaces inside square brackets
- Assuming rgba color is wrong
- Thinking drop shadow can't be used with clip-path
Solution
Step 1: Identify correct clip-path polygon for star
The polygon points in clip-path-[polygon(50%_0%,61%_35%,98%_35%,68%_57%,79%_91%,50%_70%,21%_91%,32%_57%,2%_35%,39%_35%)] shadow-[drop-shadow(2px_2px_4px_rgba(0,0,0,0.25))] define a star shape using percentages and underscores for spaces.Step 2: Check drop shadow syntax and subtlety
clip-path-[polygon(50%_0%,61%_35%,98%_35%,68%_57%,79%_91%,50%_70%,21%_91%,32%_57%,2%_35%,39%_35%)] shadow-[drop-shadow(2px_2px_4px_rgba(0,0,0,0.25))] uses shadow-[drop-shadow(2px_2px_4px_rgba(0,0,0,0.25))], a subtle shadow offset bottom-right with correct syntax.Final Answer:
clip-path-polygon star with subtle drop shadow using underscores -> Option CQuick Check:
Star shape + correct drop shadow syntax = clip-path-[polygon(50%_0%,61%_35%,98%_35%,68%_57%,79%_91%,50%_70%,21%_91%,32%_57%,2%_35%,39%_35%)] shadow-[drop-shadow(2px_2px_4px_rgba(0,0,0,0.25))] [OK]
- Using invalid class names like clip-star
- Incorrect drop shadow syntax without brackets
- No shadow or zero offset shadow
