CSS Generator

Box Shadow Generator

Create beautiful CSS box shadows visually with live preview, multiple shadow layers, presets and instant CSS code.

  • Free
  • No signup
  • Instant preview
  • Browser-based
  • Copy CSS instantly

Shadow Studio

🔒 Your CSS is generated locally in your browser
Preview
Shadow settings
Layers

    The first layer paints on top — use ↑ ↓ to reorder.

    Generated CSS
    .box {
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    }
    CSS variable mode

    Presets
    Preview settings — stage, box colour, radius, size

    These change the preview only. None of them appear in the generated box-shadow.

    Stage background

    CSS box shadow syntax

    Every shadow this tool produces follows the standard property. Only the two offsets are required; everything else has a sensible default.

    box-shadow: [inset] <offset-x> <offset-y> <blur-radius> <spread-radius> <color>;
    • offset-xMoves the shadow horizontally. Positive is right, negative is left, 0 keeps it centred.
    • offset-yMoves the shadow vertically. Positive is down, negative is up. Most interface shadows use a positive value, because light usually comes from above.
    • blur-radiusHow far the edge fades. 0 is a hard edge; larger values are softer. Cannot be negative.
    • spread-radiusGrows or shrinks the shadow before blurring. Negative values pull it in, which stops a large soft shadow leaking out sideways.
    • colorAny CSS colour. A low-opacity black blends with whatever is behind the element; a solid grey only looks right on one background.
    • insetOptional keyword, written first. Draws the shadow inside the border box so the element looks recessed.

    For more than one shadow, separate them with commas. The first one in the list is painted on top:

    box-shadow:
      0 4px 6px rgba(0, 0, 0, 0.1),
      0 10px 20px rgba(0, 0, 0, 0.08);
    Order matters. Swapping two layers changes what you see, because each is painted over the one after it. The layer list above lets you reorder with ↑ and ↓ so you can watch the difference rather than guess at it.

    Shadow recipes

    Starting points worth knowing by heart. Every one of these is reproducible in the controls above — they are the same values the presets load.

    Basic

    The smallest shadow that still separates an element from the page.

    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);

    Soft

    Blur several times the offset, low opacity. Reads as diffuse daylight.

    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);

    Strong

    Bigger offset and higher opacity, blur kept moderate so it stays crisp.

    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);

    Inset

    For inputs, wells and pressed states — the element sinks into the surface.

    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.15);

    Card

    A tight contact shadow plus a wide ambient one. Two layers beat one.

    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 8px 24px -4px rgba(0, 0, 0, 0.12);

    Neumorphic

    Opposite offsets, light where the light is. Box and background must match.

    box-shadow: -8px -8px 16px rgba(255, 255, 255, 0.9), 8px 8px 16px rgba(154, 165, 177, 0.6);

    Working with CSS box shadows

    What is a CSS box shadow?

    A box shadow is a shadow painted around — or inside — an element's border box using the box-shadow property. It follows the shape of that box exactly, including any border-radius, so a pill-shaped button automatically casts a pill-shaped shadow with no extra work.

    The single most useful thing to know about it is that a shadow occupies no space. It is painted outside the layout flow, so adding one never resizes the element, never pushes its neighbours around and never triggers a reflow. That is the fundamental difference between a shadow and a border, and it is why shadows are the safe way to add depth to a layout that is already working.

    Because shadows are painted rather than laid out, they can also overlap each other and the elements around them. That is what makes multi-layer shadows possible, and it is also why a shadow with a very large blur can bleed further across the page than you expected.

    What is a box shadow generator?

    A box shadow generator is a visual editor for one CSS property. Instead of typing five numbers, reloading and squinting at the result, you move controls and watch the shadow change immediately. When it looks right, you copy the CSS.

    The value of doing it visually is not that the syntax is hard — it is not. It is that the relationship between the numbers and the result is genuinely difficult to hold in your head. The difference between 0 4px 8px and 0 8px 16px is obvious once you see them side by side and almost impossible to predict from the digits alone. Shadow design is an eye problem, not a maths problem.

    This particular generator adds a few things beyond the usual four sliders: independent X and Y offsets including negative values, unlimited-order stacking of up to twelve layers, inset support, a switchable preview background, and output either as a plain rule or as a reusable CSS custom property.

    How to use this generator

    1. Drag the Y offset until the element sits at about the height you want it to appear.
    2. Raise the blur until the edge stops looking like a duplicate of the box. A useful starting ratio is a blur roughly two to three times the offset.
    3. Drop the opacity until the shadow stops competing with your content. Most interface shadows live between 8% and 20%.
    4. Add a second layer if it still looks flat — real objects cast more than one shadow.
    5. Switch the stage background to dark and check the shadow still reads there.
    6. Press Copy CSS.

    Understanding offset-x

    The horizontal offset moves the shadow left or right. Positive values push it right, negative values push it left, and zero leaves it centred beneath the element.

    In practice, most user-interface shadows use an X offset of exactly zero. That is not a convention for its own sake: overhead lighting, which is what interfaces implicitly simulate, casts shadows straight down. A horizontal offset implies a light source off to one side, which is a deliberate stylistic choice rather than a default. When you do want it, keep it small — beyond about 8px it starts to look like the element is falling over.

    The old version of this tool could not express an X offset different from Y at all, which meant every shadow it produced was a 45-degree diagonal. That is worth stating plainly because it is exactly the kind of limitation that is easy to miss: the tool worked, it just could not make the shadow almost everyone actually wants.

    Understanding offset-y

    The vertical offset is the one that carries the illusion. It moves the shadow down (positive) or up (negative), and the distance reads directly as height above the page.

    A 2px offset says "this is resting on the surface". A 24px offset says "this is floating well above it". Modals and dropdowns use large offsets because they genuinely are above everything; buttons use tiny ones because they are not. Getting this number wrong is the most common reason a shadow feels off even when every other value is reasonable.

    Negative Y offsets — shadows cast upward — are unusual but not wrong. They suit elements anchored to the bottom of the viewport, such as a sticky action bar, where the light logically comes from the content above.

    Understanding blur-radius

    Blur controls how quickly the shadow fades out at its edge. At zero you get a hard-edged duplicate of the element's silhouette. As it increases, the edge softens and the shadow spreads outward.

    The number that matters is not the blur on its own but its ratio to the offset. A large offset with little blur reads as a sticker sitting on the page; a small offset with a large blur reads as something barely lifted. Somewhere around two to three times the offset is where most natural-looking shadows sit.

    Blur cannot be negative — the browser will reject the declaration. If you want a shadow smaller than the element, that is what spread is for.

    Understanding spread-radius

    Spread grows or shrinks the shadow before the blur is applied. A spread of 4px makes the shadow 4px larger than the element on every side; a spread of -4px pulls it in by the same amount.

    Negative spread is the more useful of the two and the more commonly overlooked. When you use a large blur to get a soft shadow, the blur pushes the shadow out sideways as well as down, and the element ends up sitting in a grey halo. Pulling the spread in by a few pixels removes the sideways bleed while leaving the downward softness intact. That is why so many good card shadows look like 0 8px 24px -4px rather than 0 8px 24px.

    Positive spread with zero blur and zero offset gives you something else entirely: a solid outline that follows the border radius. It is a useful trick for focus rings, because unlike a border it does not affect layout.

    Understanding shadow colour

    The most common mistake in shadow design is using a solid grey. A grey shadow only looks correct on one background colour; put the same element on a tinted panel and the shadow reads as a dirty smudge, because it is not transparent and therefore cannot pick up what is behind it.

    Use a low-opacity black instead. rgba(0, 0, 0, 0.15) looks like a shadow on white, on grey, on a coloured card and on a photograph, because it darkens whatever is underneath rather than replacing it.

    Tinting the shadow towards the hue of the surface it falls on is a refinement worth knowing. A shadow on a warm cream page looks better as a very dark brown than a pure black; on a deep blue interface, a dark navy shadow reads more naturally. Keep the opacity low and the effect is subtle but real.

    This generator emits plain hex when opacity is 100% and rgba() below it. Both are valid CSS; the hex form is simply shorter when there is no transparency to express.

    How inset shadows work

    The inset keyword flips the shadow inside the element's border box. Instead of the element appearing to sit above the page, it appears to be cut into it.

    The mental model stays the same: offset, blur and spread behave exactly as before, they are just applied to the inside of the box. An inset shadow with a positive Y offset darkens the top inside edge, because that is where the rim of the recess would block the light.

    Inset shadows suit text inputs, progress tracks, wells and pressed button states. They are also the standard way to build a "pressed" affordance: swap the outer shadow for an inset one on :active and the button genuinely feels like it moves.

    One limitation worth knowing: inset shadows are clipped by the element's border box, so they never extend beyond it. You cannot use inset to draw anything outside the element.

    How multiple box shadows work

    Separate shadows with commas and the browser paints all of them, first in the list on top. This is the single biggest step up in shadow quality available, and it costs nothing.

    The reason it works is that real objects do not cast one shadow. There is a tight, dark contact shadow immediately beneath the object where it meets the surface, and a much wider, fainter ambient shadow from diffuse light in the room. Simulating both is what makes a card look like an object rather than a rectangle with a grey blob under it.

    A practical two-layer recipe: a small tight shadow at low blur for contact, then a large soft one with negative spread for ambience. Three layers, as used in Material Design's elevation scale, adds a middle term and buys a little more realism at the cost of a longer declaration.

    Because the layers paint in order, moving one changes the result. There is no way to remove a single layer from an existing multi-layer value in CSS either — box-shadow is one property, so overriding it means rewriting the whole declaration. That is a good argument for storing shadows in custom properties.

    CSS shadow best practices

    • Build an elevation scale, not one-off shadows. Three or four defined levels used consistently will look more coherent than a bespoke shadow on every component.
    • Store them in custom properties. --shadow-sm through --shadow-xl makes the scale enforceable and lets you retune everything from one place. Switch on CSS Variable Mode above to get that form directly.
    • Keep the light source consistent. If one component casts its shadow downward and another to the upper-left, the interface reads as physically incoherent even if nobody can say why.
    • Check both themes. A shadow tuned on white frequently disappears on a dark surface. Dark interfaces often need a lighter inset rim rather than a darker drop shadow.
    • Do not use shadows to signal state on their own. A shadow change is invisible to a screen reader and easy to miss for low-vision users. Pair it with a colour, an outline or a label.
    • Prefer opacity over darkness. Reaching for a heavier grey is usually the wrong move; a lower-opacity black with a wider blur almost always looks better.

    Common box shadow mistakes

    • Solid grey instead of transparent black. Looks acceptable on white and wrong everywhere else.
    • Blur too small for the offset. Produces a hard duplicate of the element that reads as a printing error rather than depth.
    • Forgetting negative spread on large blurs. The shadow bleeds sideways and the element floats in a grey halo.
    • One shadow where two are needed. A single blob rarely looks like real light.
    • Opacity far too high. Anything above about 30% starts to compete with your actual content.
    • Animating box-shadow on hover across a long list. Each frame repaints the shadow; on low-end devices this is visibly expensive.
    • Adding vendor prefixes. -webkit-box-shadow and -moz-box-shadow have been unnecessary for over a decade and only add bytes.
    • Using box-shadow on a transparent image. It follows the rectangular border box, not the artwork. Use filter: drop-shadow() for that.

    Browser compatibility

    box-shadow is supported unprefixed in every browser in current use, and has been for well over a decade. That includes multiple comma-separated shadows, the inset keyword, negative spread and rgba() colours — there is no meaningful compatibility question left to answer for any of them.

    This tool therefore emits modern, standard CSS only. It does not generate -webkit-box-shadow or -moz-box-shadow, because those prefixes target browsers that no longer exist and adding them makes stylesheets larger without making anything work.

    The one genuine consideration is performance rather than support. Very large blur radii are expensive to paint, and a page with a 60px blur on every item of a long scrolling list can drop frames on low-end mobile hardware. This is not a reason to avoid shadows; it is a reason to be deliberate about how many large ones a single screen carries.

    Frequently asked questions

    What is a CSS box shadow?

    A box shadow is a shadow painted around (or inside) an element's border box using the CSS box-shadow property. It is drawn outside the layout flow, so adding one never changes the size or position of anything on the page.

    What does box-shadow do in CSS?

    It paints one or more shadows following the shape of the element's border box, including its border radius. You control the horizontal and vertical offset, how soft the edge is, how far the shadow spreads, its colour, and whether it sits outside the element or inside it.

    What is the syntax for box-shadow?

    box-shadow: [inset] offset-x offset-y blur-radius spread-radius color; Only offset-x and offset-y are required. Blur defaults to 0, spread defaults to 0, and if you omit the colour the browser uses the element's currentColor.

    What are the four main box-shadow values?

    Offset-x moves the shadow horizontally, offset-y moves it vertically, blur-radius controls how soft the edge is, and spread-radius grows or shrinks the whole shadow before it is blurred. A colour follows them.

    What is offset-x in box-shadow?

    The horizontal distance the shadow is moved. A positive value pushes it right, a negative value pushes it left, and 0 keeps it centred under the element. Most interface shadows use 0 because real overhead lighting casts shadows straight down.

    What is offset-y in box-shadow?

    The vertical distance the shadow is moved. A positive value pushes it down, a negative value pushes it up. Downward offsets read as an object lifted above the page, which is why nearly every card and button shadow uses a positive offset-y.

    What is blur-radius in box-shadow?

    How far the shadow fades out at its edge. Zero gives a hard-edged copy of the element's shape; larger values give a softer, more diffuse shadow. Blur cannot be negative.

    What is spread-radius in box-shadow?

    How much the shadow grows or shrinks before the blur is applied. A positive spread makes the shadow larger than the element on every side; a negative spread pulls it in, which is a common way to keep a large soft shadow from leaking out sideways.

    What does inset mean in box-shadow?

    The inset keyword draws the shadow inside the element's border box instead of outside it, so the element looks recessed rather than raised. It goes first in the value: box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.15).

    Can CSS have multiple box shadows?

    Yes. Separate each shadow with a comma. The first shadow in the list is painted on top of the ones after it, so order changes the result. Stacking two or three layers is how convincing depth is usually built.

    How do I create a soft shadow in CSS?

    Use a modest downward offset, a blur several times larger than that offset, and a low opacity: box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15). The large blur-to-offset ratio is what makes it read as soft rather than heavy.

    How do I create a strong shadow?

    Increase the offset and the opacity while keeping the blur moderate: box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25). Raising opacity alone tends to look muddy; raising the offset alongside it is what reads as height.

    How do I make an inner shadow in CSS?

    Add the inset keyword: box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.15). Inner shadows suit inputs, wells and pressed button states, where the element should look pushed into the surface.

    How do I create a card shadow?

    Stack a tight shadow for the contact edge with a wider, softer one for the ambient light: box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 8px 24px -4px rgba(0, 0, 0, 0.12). A single shadow rarely looks as convincing.

    How do I create a button shadow?

    Keep it small — buttons sit close to the surface. Something like box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15), 0 4px 8px -2px rgba(0, 0, 0, 0.12) works, and reducing the offset on :active makes the button feel pressed.

    How do I create a neumorphic shadow?

    Use two shadows with opposite offsets, a light one where the light source is and a darker one opposite it: box-shadow: -8px -8px 16px rgba(255, 255, 255, 0.9), 8px 8px 16px rgba(154, 165, 177, 0.6). The element and its background must be the same colour for the effect to work.

    What is the difference between box-shadow and text-shadow?

    box-shadow follows the element's rectangular border box and its border radius; text-shadow follows the glyph shapes of the text itself. text-shadow also has no spread value and no inset keyword.

    What is the difference between box-shadow and filter: drop-shadow?

    box-shadow always follows the border box, so a transparent PNG inside a div still casts a rectangular shadow. filter: drop-shadow() follows the actual painted pixels including transparency, which is what you want for logos and irregular shapes. drop-shadow has no spread and no inset.

    Can box-shadow use rgba colours?

    Yes, and it is usually the right choice. A semi-transparent black blends with whatever is behind the element, whereas a solid grey only looks correct on one background colour.

    Can box-shadow use hex colours?

    Yes. Six-digit hex works, and eight-digit hex with an alpha channel is supported in all current browsers. This generator emits plain hex when opacity is 100% and rgba() below that.

    Can box-shadow use CSS variables?

    Yes. Storing the whole value in a custom property is the usual way design systems handle elevation: --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.15); then box-shadow: var(--shadow-card). Switch on CSS Variable Mode in this tool to get that form.

    Does box-shadow affect layout?

    No. Shadows are painted outside the layout flow and take up no space, so adding one never pushes neighbouring elements around or changes the element's size. This is the main difference from adding a border.

    Does box-shadow follow border-radius?

    Yes. The shadow follows the element's border box including its rounded corners, so a pill-shaped button casts a pill-shaped shadow automatically. You do not need to change the shadow when you change the radius.

    Does box-shadow work on mobile?

    Yes, on every current mobile browser. Very large blur radii on many elements at once can cost performance on low-end devices, so prefer a few well-chosen shadows over a large blur on every card in a long list.

    Which browsers support box-shadow?

    All of them. box-shadow has been unprefixed and universally supported for well over a decade, including multiple shadows, inset and negative spread. Vendor prefixes such as -webkit-box-shadow are obsolete and this tool does not emit them.

    How do I remove a box shadow?

    Set box-shadow: none. That is also the correct way to override an inherited or utility-class shadow, since there is no way to remove just one layer from a multi-layer value without rewriting the whole declaration.

    How do I make a shadow less visible?

    Lower the opacity first, then reduce the offset. Reducing blur usually makes a shadow look sharper rather than lighter, which is the opposite of what people expect when they want a subtler effect.

    Why does my shadow look grey and muddy?

    Usually because it is a solid grey rather than a transparent black, or because the opacity is high with very little blur. Try a low-opacity black instead of a mid-grey, and make the blur at least twice the vertical offset.

    Can I animate box-shadow?

    Yes, box-shadow is animatable, but animating it on hover can be costly because the shadow is repainted every frame. A common alternative is to keep a static shadow and animate the opacity of a pseudo-element that carries a second shadow.

    Is this box shadow generator free?

    Yes. It is free, needs no sign-up, and runs entirely in your browser — nothing you build here is sent to a server.

    Other ToolAdda utilities that pair with front-end work.

    The Box Shadow Generator runs entirely in your browser. Nothing you create is uploaded, and the shadow you are working on is remembered only in this browser's local storage until you reset it. Generated CSS is standard, unprefixed box-shadow that works in every current browser.