# Hover Depth Shadow

> Fades in a deep shadow on hover with opacity, which animates more smoothly than box-shadow.

- Category: [CSS Box Shadows](https://copy-css.com/category/shadows)
- Tags: hover, transition, elevation, performance, opacity
- Live preview: https://copy-css.com/snippets/hover-depth-shadow
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<div class="depth-hover"></div>
```

## CSS

```css
.depth-hover {
  position: relative;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
  transition: transform 0.25s ease;
}

/* The big shadow lives on a pseudo-element and only its opacity animates */
.depth-hover::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 22px 40px -12px rgba(15, 23, 42, 0.35);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.depth-hover:hover {
  transform: translateY(-4px);
}

.depth-hover:hover::after {
  opacity: 1;
}
```

## Notes

- This CSS Hover Depth Shadow is 26 lines of pure CSS (0.5 KB) with no JavaScript and no dependencies. It uses transitions, transforms and box shadows.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
