mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
148 lines
6.2 KiB
Markdown
148 lines
6.2 KiB
Markdown
---
|
|
extends: _layouts.markdown
|
|
title: "Shadows"
|
|
---
|
|
|
|
# Shadows
|
|
|
|
<div class="text-xl text-slate-light mb-4">
|
|
Utilities for controlling the box shadow of an element.
|
|
</div>
|
|
|
|
@include('_partials.feature-badges', [
|
|
'responsive' => true,
|
|
'customizable' => true,
|
|
'hover' => false,
|
|
'focus' => false
|
|
])
|
|
|
|
<div class="border-t border-grey-lighter">
|
|
<table class="w-full text-left" style="border-collapse: collapse;">
|
|
<colgroup>
|
|
<col class="w-1/5">
|
|
<col class="w-2/5">
|
|
<col class="w-2/5">
|
|
</colgroup>
|
|
<thead>
|
|
<tr>
|
|
<th class="text-sm font-semibold text-grey-darker p-2 bg-grey-lightest">Class</th>
|
|
<th class="text-sm font-semibold text-grey-darker p-2 bg-grey-lightest">Properties</th>
|
|
<th class="text-sm font-semibold text-grey-darker p-2 bg-grey-lightest">Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="align-baseline">
|
|
<tr>
|
|
<td class="p-2 border-t border-smoke font-mono text-xs text-purple-dark">.shadow</td>
|
|
<td class="w-2/5 p-2 border-t border-smoke font-mono text-xs text-blue-dark">box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.15);</td>
|
|
<td class="p-2 border-t border-smoke text-sm text-grey-darker">Apply a small box shadow to an element.</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="p-2 border-t border-smoke-light font-mono text-xs text-purple-dark">.shadow-md</td>
|
|
<td class="p-2 border-t border-smoke-light font-mono text-xs text-blue-dark">box-shadow: 0 3px 6px rgba(0,0,0,.12), 0 3px 6px rgba(0,0,0,.13);</td>
|
|
<td class="p-2 border-t border-smoke-light text-sm text-grey-darker">Apply a medium box shadow to an element.</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="p-2 border-t border-smoke-light font-mono text-xs text-purple-dark">.shadow-lg</td>
|
|
<td class="p-2 border-t border-smoke-light font-mono text-xs text-blue-dark">box-shadow: 0 10px 20px rgba(0,0,0,.13), 0 6px 6px rgba(0,0,0,.13);</td>
|
|
<td class="p-2 border-t border-smoke-light text-sm text-grey-darker">Apply a large box shadow to an element.</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="p-2 border-t border-smoke-light font-mono text-xs text-purple-dark">.shadow-inner</td>
|
|
<td class="p-2 border-t border-smoke-light font-mono text-xs text-blue-dark">box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05)</td>
|
|
<td class="p-2 border-t border-smoke-light text-sm text-grey-darker">Apply a small inner box shadow to an element.</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="p-2 border-t border-smoke-light font-mono text-xs text-purple-dark">.shadow-none</td>
|
|
<td class="p-2 border-t border-smoke-light font-mono text-xs text-blue-dark">box-shadow: none;</td>
|
|
<td class="p-2 border-t border-smoke-light text-sm text-grey-darker">Remove a box shadow from an element.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
Box shadows can be applied using the `.shadow-{size}` utilities. By default these are a size scale, where the smaller sizes represent more shallow shadows, and larger sizes represent deeper shadows. If you use the `.shadow` utility without a suffix, you'll get the default shadow.
|
|
|
|
@component('_partials.code-sample', ['class' => 'flex justify-around text-sm py-8'])
|
|
<div class="mr-3 p-4 bg-smoke-lighter shadow-inner">.shadow-inner</div>
|
|
<div class="mr-3 p-4 shadow">.shadow</div>
|
|
<div class="mr-3 p-4 shadow-md">.shadow-md</div>
|
|
<div class="mr-3 p-4 shadow-lg">.shadow-lg</div>
|
|
@slot('code')
|
|
<div class="shadow-inner"></div>
|
|
<div class="shadow"></div>
|
|
<div class="shadow-md"></div>
|
|
<div class="shadow-lg"></div>
|
|
@endslot
|
|
@endcomponent
|
|
|
|
## Responsive
|
|
|
|
To control the shadow of an element at a specific breakpoint, add a `{breakpoint}:` 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](/workflow/responsive-design) documentation.
|
|
|
|
@component('_partials.responsive-code-sample')
|
|
@slot('none')
|
|
<div class="flex justify-center">
|
|
<div class="shadow px-4 py-2 bg-smoke-lighter opacity-100 w-24 h-24 rounded-pill"></div>
|
|
</div>
|
|
@endslot
|
|
@slot('sm')
|
|
<div class="flex justify-center">
|
|
<div class="shadow-md px-4 py-2 bg-smoke-lighter opacity-100 w-24 h-24 rounded-pill"></div>
|
|
</div>
|
|
@endslot
|
|
@slot('md')
|
|
<div class="flex justify-center">
|
|
<div class="shadow-lg px-4 py-2 bg-smoke-lighter opacity-100 w-24 h-24 rounded-pill"></div>
|
|
</div>
|
|
@endslot
|
|
@slot('lg')
|
|
<div class="flex justify-center">
|
|
<div class="shadow-inner px-4 py-2 bg-smoke-lighter opacity-100 w-24 h-24 rounded-pill"></div>
|
|
</div>
|
|
@endslot
|
|
@slot('xl')
|
|
<div class="flex justify-center">
|
|
<div class="shadow-none px-4 py-2 bg-smoke-lighter opacity-100 w-24 h-24 rounded-pill"></div>
|
|
</div>
|
|
@endslot
|
|
@slot('code')
|
|
<div class="none:shadow sm:shadow-md md:shadow-lg lg:shadow-inner xl:shadow-none ...">
|
|
<!-- ... -->
|
|
</div>
|
|
@endslot
|
|
@endcomponent
|
|
|
|
## Customizing
|
|
|
|
By default Tailwind provides three drop shadows and one inner shadow. You can, of course, modify these values as needed. This is done in the `shadows` section of your Tailwind config. As you can see from the defaults we provide, it's possible to apply multiple shadows per utility using comma separation.
|
|
|
|
Take note that a `default` shadow is required. This is the value used for the non-suffixed version of this utility (`.shadow`).
|
|
|
|
@component('_partials.customized-config')
|
|
@slot('default')
|
|
{
|
|
// ...
|
|
shadows: {
|
|
default: '0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.15)',
|
|
'md': '0 3px 6px rgba(0,0,0,.12), 0 3px 6px rgba(0,0,0,.13)',
|
|
'lg': '0 10px 20px rgba(0,0,0,.13), 0 6px 6px rgba(0,0,0,.13)',
|
|
'inner': 'inset 0 1px 2px rgba(0, 0, 0, 0.05)',
|
|
'none': 'none',
|
|
},
|
|
}
|
|
@endslot
|
|
@slot('customized')
|
|
{
|
|
// ...
|
|
shadows: {
|
|
default: '0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.15)',
|
|
'big': '0 3px 6px rgba(0,0,0,.12), 0 3px 6px rgba(0,0,0,.13)',
|
|
'huge': '0 10px 20px rgba(0,0,0,.13), 0 6px 6px rgba(0,0,0,.13)',
|
|
'none': 'none',
|
|
},
|
|
}
|
|
@endslot
|
|
@endcomponent
|