# Fade Edge Mask

> A horizontal scroller whose edges fade out with a mask gradient, hinting that there is more to scroll.

- Category: [CSS Gradients & Patterns](https://copy-css.com/category/gradients)
- Tags: mask-image, scroll, overflow, carousel, fade out
- Live preview: https://copy-css.com/snippets/fade-edge-mask
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<ul class="fade-edges" tabindex="0" aria-label="Topics">
  <li>Design</li>
  <li>Development</li>
  <li>Marketing</li>
  <li>Product</li>
  <li>Research</li>
  <li>Writing</li>
  <li>Sales</li>
  <li>Support</li>
</ul>
```

## CSS

```css
.fade-edges {
  --fade: 40px;
  display: flex;
  gap: 8px;
  width: min(100%, 300px);
  margin: 0;
  padding: 4px 0;
  overflow-x: auto;
  list-style: none;
  scrollbar-width: none;
  -webkit-mask: linear-gradient(90deg, #0000, #000 var(--fade), #000 calc(100% - var(--fade)), #0000);
  mask: linear-gradient(90deg, #0000, #000 var(--fade), #000 calc(100% - var(--fade)), #0000);
}

.fade-edges::-webkit-scrollbar {
  display: none;
}

.fade-edges li {
  flex: none;
  padding: 8px 14px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font: 600 14px/1 system-ui, sans-serif;
}

/* Drawn inside the box so the mask does not hide it */
.fade-edges:focus-visible {
  border-radius: 8px;
  outline: 2px solid #4f46e5;
  outline-offset: -2px;
}
```

## Notes

- This CSS Fade Edge Mask is 33 lines of pure CSS (0.7 KB) with no JavaScript and no dependencies. It uses linear gradients, masks, Flexbox and keyboard focus styles.
- Customize with: `--fade`.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
