Small Shadow
Default Shadow
Medium Shadow
Large Shadow
Extra Large Shadow
2XL Shadow
[Try it Β»](#)
### Shadow Level Comparison Table
| Class Name | Description | Use Case |
| --- | --- | --- |
| shadow-sm | Very subtle shadow | Button hover, slight elevation |
| shadow | Default shadow (medium size) | Cards, regular elements |
| shadow-md | Medium shadow | Modals, important notifications |
| shadow-lg | Large shadow | Floating panels, highlighted elements |
| shadow-xl | Extra large shadow | Special emphasis elements |
| shadow-2xl | 2XL shadow | Elements that need very obvious emphasis |
### Code Examples and Practice
## Example
Tailwind Shadow Example
This is a card example using shadow-md
Title with Shadow
### Method 2: Custom Utility Class Add in CSS: ## Example @layer utilities { .text-shadow{ text-shadow:2px 2px 4px rgba(0,0,0,0.5); } .text-shadow-sm{ text-shadow:1px 1px 2px rgba(0,0,0,0.5); } } * * * ## Shadow Color and Opacity Control Tailwind allows you to control the color and opacity of shadows through utility class combinations. ### 1. Using Shadow Color Utility Classes ## ExampleBlue Semi-transparent Shadow
Syntax analysis:
* `shadow-{color}`: Sets shadow color (e.g., blue-500)
* `/{opacity}`: Sets shadow opacity (e.g., 50 means 50%)
### 2. Available Colors and Opacity
Tailwind supports all built-in colors and any opacity values:
## Example
Red Semi-transparent Shadow
Emerald Green Strong Shadow
Purple Light Shadow
### 3. Custom Shadow Color
Extend in `tailwind.config.js`:
## Example
module.exports={
theme:{
extend:{
boxShadow:{
'custom':'0 4px 6px -1px rgba(156, 39, 176, 0.3)',
}
}
}
}
* * *
## Inner Shadow Effect (inset)
Inner shadows can create a sunken or pressed effect, commonly used for interactive elements like buttons and input fields.
### 1. Using Preset Inner Shadow Classes
## Example
Inner Shadow Effect
### 2. Custom Inner Shadow
Add in configuration file:
## Example
module.exports={
theme:{
extend:{
boxShadow:{
'inner-lg':'inset 0 4px 6px 0 rgba(0, 0, 0, 0.1)',
}
}
}
}
### 3. Practical Application Example
## Example
**Effect Description**:
* Default state has slight inner shadow
* Inner shadow intensifies on hover (`hover:shadow-inner-lg`)
* Creates a visual effect of the button being pressed
* * *
## Advanced Tips and Best Practices
### 1. Combine Inner and Outer Shadows
## Example
Outer Shadow + Inner Shadow Combination
### 2. Responsive Shadow
## Example
Small shadow on small screens, large shadow on large screens
### 3. Hover and Focus States
## Example
### 4. Shadow Animation
## Example
* * *
## Practice Challenges
1. Create a card component with medium shadow by default, shadow grows and changes color on hover
2. Design an input box with inner shadow, inner shadow disappears when focused
3. Implement a text title using text-shadow to create a neon effect
4. Combine inner and outer shadows to create a 3D button
* * *
## Summary Points
### Core Utility Classes Quick Reference
| Function | Class Example | Description |
| --- | --- | --- |
| Box Shadow | shadow, shadow-lg | Different sizes of outer shadow |
| Inner Shadow | shadow-inner | Inner shadow of element |
| Shadow Color | shadow-blue-500 | Sets shadow color |
| Shadow Opacity | shadow-blue-500/50 | Sets shadow opacity |
| Text Shadow | text-shadow (requires custom) | Adds shadow to text |
### Best Practice Suggestions
1. **Use in Moderation**: Shadows should enhance the design, not distract
2. **Stay Consistent**: Maintain similar shadow hierarchies throughout the project
3. **Consider Performance**: Too many complex shadows may affect rendering performance
4. **Combine with Other Properties**: Shadows work better when combined with rounded corners and transition effects
YouTip