Box Shadow
Utilities for controlling the box shadow of an element.
Class reference
Class | Properties |
---|---|
.shadow-xs | box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05); |
.shadow-sm | box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); |
.shadow | box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); |
.shadow-md | box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); |
.shadow-lg | box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); |
.shadow-xl | box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); |
.shadow-2xl | box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); |
.shadow-inner | box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06); |
.shadow-outline | box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.5); |
.shadow-none | box-shadow: none; |
Outer shadow
Use the .shadow-xs
, .shadow-sm
, .shadow
, .shadow-md
, .shadow-lg
, .shadow-xl
, or .shadow-2xl
utilities to apply different sized outer box shadows to an element.
<div class="shadow-xs"></div>
<div class="shadow-sm"></div>
<div class="shadow"></div>
<div class="shadow-md"></div>
<div class="shadow-lg"></div>
<div class="shadow-xl"></div>
<div class="shadow-2xl"></div>
Inner shadow
Use the .shadow-inner
utility to apply a subtle inset box shadow to an element. This can be useful for things like form controls or wells.
<div class="shadow-inner"></div>
Focus outline shadow
Use the .shadow-outline
utility to apply a focus-ring-style shadow to an element. This can be useful when combined with .focus:outline-none
to create a better looking focus style that follows an element’s border radius.
<button class="focus:outline-none focus:shadow-outline ...">
Button
</button>
No shadow
Use .shadow-none
to remove an existing box shadow from an element. This is most commonly used to remove a shadow that was applied at a smaller breakpoint.
<div class="shadow-none"></div>
Responsive
To control the shadow of an element at a specific breakpoint, add a {screen}:
prefix to any existing shadow utility. For example, use md:shadow-lg
to apply the shadow-lg
utility at only medium screen sizes and above.
For more information about Tailwind’s responsive design features, check out the Responsive Design documentation.
all
sm
md
lg
xl
<div class="shadow sm:shadow-md md:shadow-lg lg:shadow-xl xl:shadow-2xl ...">
<!-- ... -->
</div>
Customizing
Box Shadows
By default Tailwind provides three drop shadow utilities, one inner shadow utility, and a utility for removing existing shadows. You can change, add, or remove these by editing the theme.boxShadow
section of your Tailwind config.
If a default
shadow is provided, it will be used for the non-suffixed .shadow
utility. Any other keys will be used as suffixes, for example the key '2'
will create a corresponding .shadow-2
utility.
// tailwind.config.js
module.exports = {
theme: {
boxShadow: {
xs: '0 0 0 1px rgba(0, 0, 0, 0.05)',
sm: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
default: '0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)',
md: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
lg: '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',
xl: '0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)',
'2xl': '0 25px 50px -12px rgba(0, 0, 0, 0.25)',
+ '3xl': '0 35px 60px -15px rgba(0, 0, 0, 0.3)',
inner: 'inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)',
- outline: '0 0 0 3px rgba(66, 153, 225, 0.5)',
+ focus: '0 0 0 3px rgba(66, 153, 225, 0.5)',
none: 'none',
}
}
}
Responsive and pseudo-class variants
By default, only responsive, hover and focus variants are generated for box shadow utilities.
You can control which variants are generated for the box shadow utilities by modifying the boxShadow
property in the variants
section of your tailwind.config.js
file.
For example, this config will also generate active and group-hover variants:
// tailwind.config.js
module.exports = {
variants: {
// ...
- boxShadow: ['responsive', 'hover', 'focus'],
+ boxShadow: ['responsive', 'hover', 'focus', 'active', 'group-hover'],
}
}
Disabling
If you don’t plan to use the box shadow utilities in your project, you can disable them entirely by setting the boxShadow
property to false
in the corePlugins
section of your config file:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
+ boxShadow: false,
}
}