import { Meta, Canvas, Story } from '@storybook/addon-docs';
# Shadow
Shadows convey elevation of elements on a surface
## Size
There are 4 different sizes of shadow in MetaMask
| Size | CSS |
| ------ | ----------------------- |
| **XS** | `var(--shadow-size-xs)` |
| **SM** | `var(--shadow-size-sm)` |
| **MD** | `var(--shadow-size-md)` |
| **LG** | `var(--shadow-size-lg)` |
## Color
As well as the neutral colors for shadow 2 other colors exist that are used for the primary and error/danger button hover states
Default
Primary
Error/Danger
| Color | CSS |
| ----------- | ----------------------------- |
| **neutral** | `var(--color-shadow-default)` |
| **primary** | `var(--color-primary-shadow)` |
| **danger** | `var(--color-error-shadow)` |
## Example usage
Using both size and color tokens, different shadows can be applied to components
Card
Dropdown
Toast
Modal
Button Primary Hover
Button Error/Danger Hover
| Component | JS | CSS |
| ------------------------ | ---------------------------------------------------------------- | --- |
| **Card** | `box-shadow: var(--shadow-size-xs) var(--color-shadow-default);` |
| **Dropdown** | `box-shadow: var(--shadow-size-sm) var(--color-shadow-default);` |
| **Toast** | `box-shadow: var(--shadow-size-md) var(--color-shadow-default);` |
| **Modal** | `box-shadow: var(--shadow-size-lg) var(--color-shadow-default);` |
| **Button Primary Hover** | `box-shadow: var(--shadow-size-sm) var(--color-primary-shadow);` |
| **Button Danger Hover** | `box-shadow: var(--shadow-size-sm) var(--color-error-shadow);` |
## Takeaways
- Try to avoid using static media queries in your code
- Try to use the provided SCSS mixins
### ❌ Don't do this
Don't use static media queries in your code
```css
/**
* Don't do this
* Static box-shadows create inconsistency in elevation of elements
**/
.card {
box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.2);
}
```
### ✅ Do this
Do use the provided shadow design token css variables
```css
.card {
box-shadow: var(--shadow-size-xs) var(--color-shadow-default);
}
```
## References
- [Shadow design tokens](https://metamask.github.io/design-tokens/?path=/docs/shadows-shadows--shadow)
- [Figma light theme colors library(shadows page)](https://www.figma.com/file/kdFzEC7xzSNw7cXteqgzDW/%5BColor%5D-Light-Theme?node-id=753%3A719)(internal use only)
- [Figma dark theme colors library(shadows page)](https://www.figma.com/file/rLKsoqpjyoKauYnFDcBIbO/%5BColor%5D-Dark-Theme?node-id=522%3A1022)(internal use only)