Use shadow-elevation-0 to shadow-elevation-5 for the shadows of the six Material 3 elevation levels. Each level is also a custom property, such as var(--md-sys-elevation-level2), and all of them take their color from one color role.
Elevation levels
The theme's shadows follow Material's elevation levels: six levels, each a distance above the surface behind it. A higher level has a larger and softer shadow.
shadow-elevation-0shadow-elevation-1shadow-elevation-2shadow-elevation-3shadow-elevation-4shadow-elevation-5| Class and token | Height | Resting level of |
|---|---|---|
shadow-elevation-0--md-sys-elevation-level0 | 0dp | Filled, tonal and outlined buttons, filled and outlined cards, lists and tabs |
shadow-elevation-1--md-sys-elevation-level1 | 1dp | Elevated buttons, cards and chips, and modal sheets |
shadow-elevation-2--md-sys-elevation-level2 | 3dp | Menus, rich tooltips, toolbars and scrolled app bars |
shadow-elevation-3--md-sys-elevation-level3 | 6dp | FABs, dialogs, search, and date and time pickers |
shadow-elevation-4--md-sys-elevation-level4 | 8dp | Not a resting level |
shadow-elevation-5--md-sys-elevation-level5 | 12dp | Not a resting level |
Material keeps an element's resting state on levels 0 to 3, and reserves levels 4 and 5 for states such as hover and dragged.
An elevation class is one of Tailwind's box shadow utilities, and is used like any other:
- Surface color: Material shows elevation with color first: surfaces are told apart by their tone. Give a raised surface a surface container role, and add a shadow where it needs more separation from what is behind it, or to encourage interaction.
- States: Add a state variant for another level in a state, as in
hover:shadow-elevation-2. Material usually raises a component by one level when it is hovered or focused. - Transitions: To animate the change, add a transition preset, such as
transition-color-shadow, or Tailwind'stransition-shadowwith one of the theme's durations and easings. - Tailwind's shadows: Tailwind's own shadows, such as
shadow-md, are unchanged. Use them next to the levels. - Shadow color: Tailwind's shadow color classes, such as
shadow-primary, do not re-color a level. To re-color the levels, see Shadow color. - Your own CSS: Apply a level with Tailwind's
@apply, as in@apply shadow-elevation-2, or use its custom property, as inbox-shadow: var(--md-sys-elevation-level2). - Merged classes: tailwind-merge does not know the levels, and keeps a level next to one of Tailwind's shadows, such as
shadow-none. To merge them, use thetvor thetwMergethat@material-web/reactexports, where the later class replaces the earlier one.
Forced colors
In forced colors mode the browser drops shadows, and fills with them, which leaves an elevated container with no edge. Add forced-colors:container-border to give it one:
<div class="bg-surface-container-low shadow-elevation-1 forced-colors:container-border"></div>See Accessibility.
Custom elevation
Every level, and the color of its shadows, is a custom property, so your own CSS can set it after the import. A value set before the import is replaced by the theme's.
| Token and theme variable | Default | Components that use it, such as |
|---|---|---|
--md-sys-color-shadow--color-shadow | Black, the neutral palette's tone 0 | Every component with a shadow |
--md-sys-elevation-level0--shadow-elevation-0 | none | None |
--md-sys-elevation-level1--shadow-elevation-1 | 0 1px 2px 0, 0 1px 3px 1px | Elevated button, card and chip, bottom sheet, modal side sheet |
--md-sys-elevation-level2--shadow-elevation-2 | 0 1px 2px 0, 0 2px 6px 2px | Menu, rich tooltip, floating toolbar, a hovered elevated button |
--md-sys-elevation-level3--shadow-elevation-3 | 0 1px 3px 0, 0 4px 8px 3px | FAB, FAB menu, snackbar |
--md-sys-elevation-level4--shadow-elevation-4 | 0 2px 3px 0, 0 6px 10px 4px | A hovered FAB, a dragged list item |
--md-sys-elevation-level5--shadow-elevation-5 | 0 4px 4px 0, 0 8px 12px 6px | None |
Under each token is its Tailwind theme variable, which gives the token its classes. In your own CSS, read the token, as in var(--md-sys-elevation-level2): a theme variable has the root's value, and does not follow a token set on an element.
Shadow color
A level's shadows are in the shadow color role. Set --md-sys-color-shadow on the root to re-color the shadows of every level:
@import 'tailwindcss';
@import '@material-web/tailwind';
:root {
--md-sys-color-shadow: #1a237e;
}Set the color on the root. A color set on another element does not reach the levels.
Level tokens
Each level is two shadows in the shadow color, a key shadow at 30% and an ambient shadow at 15%. The table above lists the offsets, the blur and the spread of both. To change a level, set its token to any box-shadow value:
:root {
--md-sys-elevation-level1: 0 1px 2px
color-mix(in srgb, var(--md-sys-color-shadow) 20%, transparent);
}A level you set changes every class and every component that uses it.
- One part of the page: Set a level token on an element, in place of the root, to change the shadows inside it only.
- One component: Pass an elevation class in the component's
className, as in<Card className="shadow-elevation-2">. - Default levels: Material advises against changing the default elevation of its components, and recommends a small number of levels in a product.