Generate a CSS box-shadow value
Set the shift, blur, spread and color of a shadow and get a CSS box-shadow ready to paste: 4, 8, 16 and 0 become 4px 8px 16px 0px followed by your color. Negative blur or spread is refused. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Offset x
- 4
- Offset y
- 8
- Blur
- 16
- Spread
- 0
- Color
- rgb(15 23 42 / 0.25)
- Box shadow
- 4px 8px 16px 0px rgb(15 23 42 / 0.25)
Build a copy-ready CSS box-shadow value from five explicit inputs instead of assembling the syntax by hand. Provide horizontal and vertical offsets, a blur radius, a spread radius, and any supported CSS color value. The generator validates the numeric fields, rejects negative blur or spread values, and returns a consistently formatted shadow using pixel units. It is useful for interactive design work, design-token pipelines, component generators, and tests that need the same output from the same input every time.
Set the shadow position with horizontal and vertical offsets
Both values are expressed in CSS pixels in the generated result. A positive horizontal offset moves the shadow toward the right, while a negative value moves it toward the left. A positive vertical offset moves it downward, while a negative value moves it upward.
Zero keeps the shadow centered on that axis. These fields may be decimal values when a design system uses fractional spacing, and the generator preserves the validated numeric value rather than silently rounding it. Think about the apparent light source when choosing offsets: a light above and to the left usually produces a shadow below and to the right.
Small offsets tend to feel close and subtle, whereas large offsets can make an element appear elevated or deliberately graphic. The tool does not infer direction from blur, color, or component type, so the values remain under your control and can be reproduced exactly across stylesheets and builds.
Control softness and footprint with blur and spread
The blur radius controls how gradually the shadow transitions from its strongest area into transparency. A value of zero creates a hard edge, while larger values create a softer and visually wider shadow. The spread radius expands the shadow shape before blur is applied.
Zero follows the element's original shadow footprint, and a positive spread makes the footprint extend outward on every side. Enter each value as a plain number; the returned CSS adds px units in the required order. Blur and spread are different controls, so increasing one is not a substitute for increasing the other.
For a restrained interface shadow, pair a modest offset with moderate blur and little or no spread. For a strong focus ring or poster-like effect, zero blur and a larger spread can produce a crisp outline. Preview the result against the actual surface because perceived softness changes with contrast and surrounding colors.
Choose a color and apply the generated value
The color field accepts one nonempty CSS color value, including a named color, hexadecimal notation, or a functional form such as rgb() or hsl(). Alpha transparency is often important for natural shadows because an opaque dark color can look heavy on light surfaces and muddy on colored backgrounds. The generator trims unnecessary surrounding whitespace, checks balanced parentheses, and rejects declaration-breaking characters.
Assign that value to the box-shadow property, place it in a custom property, or store it as a design token. The response is a value rather than a complete declaration, so your application still chooses the selector and whether to combine it with other shadow layers. For multiple shadows, generate and review each layer separately before joining the values with commas.
Execution is deterministic and has no network, model, randomness, storage, or clock dependency, which makes the output suitable for snapshots and repeatable build automation.
What you can do with it
Create a component shadow token
Turn structured design settings into a stable box-shadow value for cards, menus, dialogs, and floating controls.
Power a visual style editor
Convert slider and color-picker values into copyable CSS while rejecting invalid negative blur or spread settings.
Generate repeatable stylesheet output
Use the deterministic result in a build script, component generator, snapshot test, or theme configuration pipeline.
FAQ
Can the horizontal or vertical offset be negative?
Yes. Negative horizontal offsets move the shadow left, and negative vertical offsets move it upward.
Which units does the output use?
All four numeric values are emitted in pixels. Supply plain finite numbers without adding unit text.
Does it generate multiple shadow layers?
Generate layers separately and join reviewed values with commas when your CSS needs multiple shadows.
What is the difference between blur and spread in a box-shadow?
Blur softens the edge: zero gives a hard edge and larger values a softer, wider fade. Spread grows the shadow shape outward on every side before the blur is applied, so raising one does not replace the other.
How do I make a shadow semi-transparent?
Use a color with transparency, such as an rgb() or hsl() value with an alpha part, like rgb(15 23 42 / 0.25). An opaque dark color tends to look heavy, while a translucent one reads as a natural shadow.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/web/box-shadow-generate \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"offset_x":4,"offset_y":8,"blur":16,"spread":0,"color":"rgb(15 23 42 / 0.25)"}'const res = await fetch("https://api.kit.forhosting.com/web/box-shadow-generate", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"offset_x": 4,
"offset_y": 8,
"blur": 16,
"spread": 0,
"color": "rgb(15 23 42 / 0.25)"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/web/box-shadow-generate",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"offset_x": 4,
"offset_y": 8,
"blur": 16,
"spread": 0,
"color": "rgb(15 23 42 / 0.25)"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/web/box-shadow-generate", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"offset_x":4,"offset_y":8,"blur":16,"spread":0,"color":"rgb(15 23 42 / 0.25)"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"offset_x":4,"offset_y":8,"blur":16,"spread":0,"color":"rgb(15 23 42 / 0.25)"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/web/box-shadow-generate", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"offset_x": 4,
"offset_y": 8,
"blur": 16,
"spread": 0,
"color": "rgb(15 23 42 / 0.25)"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "web.box_shadow_generate",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
timeout_sec | 30 |
max_crawl_pages | 25 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Set the shadow position with horizontal and vertical offsets
Start with offset_x and offset_y, which determine where the shadow is displaced relative to the element.
Control softness and footprint with blur and spread
This capability intentionally rejects negative blur and negative spread values, giving the request a simple nonnegative contract and a clear invalid_input error instead of producing an unexpected style.
Choose a color and apply the generated value
It returns a box_shadow field containing the five parts in canonical CSS order: horizontal offset, vertical offset, blur radius, spread radius, and color. This generator produces one shadow layer per request.
Technical questions
What does one generated value cost?
The browser runner is free. A successful API request costs $0.002 for one generated item.
Can blur or spread be negative?
No. This capability requires both blur and spread to be zero or greater and returns an invalid_input error otherwise.