Eskillsfy

Home / Blog / Web and CSS

Web and CSS · 23 Nov 2026

CSS Box Shadow Generator: how it works and how to build one

Build layered box shadows visually and copy the CSS. This guide explains what happens behind the button and shows the code, so you can build your own.

What it does

Set offset, blur, spread, color and opacity for one or more shadow layers, including inset shadows, and see them on a card. Presets include soft, hard (like this site) and neumorphic styles.

When to use it

  • Cards and modals
  • Buttons
  • Neumorphic and hard-shadow styles

How to use it

  1. Pick a preset or add layers.
  2. Adjust each layer with sliders.
  3. Copy the box-shadow CSS.

Try it free in your browser, nothing is uploaded: https://eskillsfy.com/tools/box-shadow-generator

How it works

box-shadow takes a comma-separated list of shadows, each with an x and y offset, blur radius, spread and color, and an optional inset keyword. Layering two or three soft shadows (a tight one and a wide one) looks more natural than one big shadow.

The tool keeps an array of layer objects and joins them into the CSS string on every change.

Build it yourself

Here is the core of the tool. It has no dependencies unless noted, so you can paste it into any TypeScript or JavaScript project.

shadow.ts (ts)

type Layer = { x: number; y: number; blur: number; spread: number; color: string; alpha: number; inset?: boolean };

const rgba = (hex: string, a: number) => {
  const v = parseInt(hex.slice(1), 16);
  return `rgba(${v >> 16}, ${(v >> 8) & 255}, ${v & 255}, ${a})`;
};

export const boxShadow = (layers: Layer[]) =>
  layers.map((l) => `${l.inset ? "inset " : ""}${l.x}px ${l.y}px ${l.blur}px ${l.spread}px ${rgba(l.color, l.alpha)}`).join(", ");

Make it production-ready

  • Add hover-state preview.
  • Export as Tailwind arbitrary values.

Questions

Why use several layers?

Two or three soft layers look more natural than one big blurry shadow.

Try the CSS Box Shadow Generator

Free, runs in your browser, nothing is uploaded.

Open it
Keep reading

More in Web and CSS

All posts