Skip to main content

Box Shadow Generator

Generate CSS box-shadow code with visual preview for drop shadows, inset, and layered effects. Enter values for instant results with step-by-step formulas.

Skip to calculator
Creative & Design

Box Shadow Generator

Generate CSS box-shadow code with visual preview for drop shadows, inset, and layered effects.

Last updated: December 2025

Calculator

Adjust values & calculate
Shadow renders outside the element
Live Preview
Generated CSS
box-shadow: 4px 4px 12px 0px rgba(0, 0, 0, 0.25);
Shadow Distance
5.7px
Shadow Angle
45 deg
Total Spread
12px
RGBA Color
rgba(0, 0, 0, 0.25)
Your Result
CSS: box-shadow: 4px 4px 12px 0px rgba(0, 0, 0, 0.25); | Distance: 5.7px at 45 degrees
Share Your Result
Understand the Math

Formula

box-shadow: [inset] h-offset v-offset blur spread color

The box-shadow property accepts an optional inset keyword, horizontal offset, vertical offset, blur radius, spread radius, and color. Positive horizontal values move the shadow right, positive vertical values move it down. Blur softens edges and spread expands or contracts the shadow.

Last reviewed: December 2025

Worked Examples

Example 1: Material Design Card Shadow

Create a subtle shadow for a card component that looks elevated, similar to Material Design elevation level 2.
Solution:
Use no horizontal offset, 4px vertical offset, 12px blur, and 0 spread with 15% opacity black. box-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.15); The zero horizontal offset keeps the shadow centered. The 4px vertical offset simulates a top-down light source. 12px blur creates a soft, natural gradient at the edges.
Result: CSS: box-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.15); โ€” clean elevated card shadow.

Example 2: Floating Button Shadow

Create a prominent shadow for a floating action button that appears to hover above the page with significant depth.
Solution:
Use 0px horizontal, 10px vertical, 25px blur, and -5px spread with 20% opacity. box-shadow: 0px 10px 25px -5px rgba(0, 0, 0, 0.20); The -5px spread prevents the shadow from extending beyond the button width. The 25px blur creates a very soft, diffused shadow. 10px vertical offset implies the button is significantly elevated.
Result: CSS: box-shadow: 0px 10px 25px -5px rgba(0, 0, 0, 0.20); โ€” dramatic floating shadow.
Expert Insights

Background & Theory

The Box Shadow Generator applies the following established principles and formulas. Computers represent all information using binary, a base-2 number system consisting solely of the digits 0 and 1, each called a bit. Because long binary strings are unwieldy, programmers routinely use octal (base 8) and hexadecimal (base 16) as compact shorthand. Converting between bases follows a consistent algorithm: divide the source number repeatedly by the target base, collecting remainders in reverse order. Hexadecimal digits A through F represent the values 10 through 15, allowing a single character to encode four binary bits, making it the preferred notation for memory addresses, color codes, and bytecode. Bitwise operations manipulate individual bits within integers. AND produces a 1 only when both input bits are 1, making it useful for masking. OR produces a 1 when either bit is 1 and is used for combining flags. XOR flips bits that differ, enabling simple toggle logic and efficient swap algorithms. NOT inverts every bit (one's complement), while left and right shifts multiply or divide by powers of two in constant time. Data storage units ascend in binary multiples of 1024: 8 bits form one byte, 1024 bytes form one kibibyte (KiB), 1024 KiB form one mebibyte (MiB), and so forth. Hard-drive manufacturers historically use decimal prefixes (1 KB = 1000 bytes), creating the persistent confusion between binary and decimal interpretations of the same label. The IEC standardized the binary prefixes KiB, MiB, GiB, and TiB in 1998 to resolve this ambiguity. Network bandwidth is measured in bits per second (bps), most commonly megabits per second (Mbps) or gigabits per second (Gbps). A 100 Mbps connection transfers 100 million bits every second, equating to roughly 12.5 megabytes per second. IP subnet masks define network boundaries; CIDR notation appends a prefix length (e.g., /24) to an address, indicating how many leading bits are fixed. A /24 subnet contains 256 addresses with 254 usable hosts. Algorithm efficiency is described using Big-O notation, which characterises the worst-case growth of time or space relative to input size. O(1) is constant, O(log n) is logarithmic (binary search), O(n) is linear, and O(nยฒ) is quadratic. Cryptographic hash functions like SHA-256 produce a fixed 256-bit (32-byte) digest regardless of input length. File compression algorithms exploit statistical redundancy to reduce storage footprint, and compression ratio equals the original file size divided by the compressed size.

History

The history behind the Box Shadow Generator traces back through the following developments. The conceptual foundation of modern computing traces back to Charles Babbage, whose Analytical Engine design of 1837 introduced the idea of a general-purpose mechanical computer with separate storage and processing units, including what he called the Store and the Mill. Ada Lovelace wrote what many consider the first algorithm intended for machine execution while annotating a translation of Luigi Menabrea's account of Babbage's work, also recognising the machine's potential to manipulate symbols beyond mere numbers. George Boole published "The Laws of Thought" in 1854, formalising a two-valued algebra of logic that would later map perfectly to electrical circuits. It remained largely a mathematical curiosity until Claude Shannon's landmark 1937 master's thesis demonstrated that Boolean algebra could describe switching circuits, laying the theoretical groundwork for all digital electronics. Shannon's 1948 paper "A Mathematical Theory of Communication" defined the bit as the fundamental unit of information and established information theory as a rigorous discipline. The same year, the transistor was invented at Bell Labs by Bardeen, Brattain, and Shockley, eventually replacing vacuum tubes and enabling miniaturisation at scale. ENIAC, completed in 1945, was one of the first general-purpose electronic computers, occupying 1800 square feet and consuming 150 kilowatts of power while performing roughly 5000 additions per second. The ASCII standard was ratified in 1963, assigning 7-bit codes to 128 characters and enabling interoperability between computers from different manufacturers. Through the 1970s, the microprocessor consolidated an entire CPU onto a single chip; Intel's 4004 in 1971 marked the beginning of this trend. The Apple II launched in 1977 and the IBM PC in 1981 brought computing to homes and offices, triggering a mass-market software industry. Tim Berners-Lee proposed the World Wide Web in 1989 and launched the first website in 1991 at CERN, transforming the internet from an academic and military network into a global information infrastructure. Mobile computing accelerated through the 2000s with smartphones integrating powerful processors, wireless networking, and GPS into pocket-sized devices, extending computation into every facet of daily life and cementing TCP/IP as the universal communications fabric.

Share this calculator

Explore More

Frequently Asked Questions

Blur and spread work together to define the shadow shape and softness. The blur radius creates a Gaussian blur effect, where a value of zero produces a sharp-edged shadow identical to the element shape. Larger blur values make the shadow progressively softer and more diffused. The spread radius expands (positive values) or contracts (negative values) the shadow before the blur is applied. A positive spread makes the shadow larger than the element, useful for creating glow effects. A negative spread makes the shadow smaller, which when combined with a vertical offset and large blur, creates realistic elevated shadows. Understanding these two properties independently gives you precise control over shadow aesthetics.
Box-shadow and the drop-shadow filter produce similar visual effects but work fundamentally differently. Box-shadow applies a shadow to the rectangular box model of an element, meaning it always creates a rectangular shadow regardless of the element content shape. The drop-shadow CSS filter, on the other hand, respects the alpha channel of the element, creating shadows that follow the actual shape of transparent images or text. Box-shadow also supports the spread radius and inset keyword, which drop-shadow does not. Performance-wise, box-shadow is generally faster because it does not require compositing. For rectangular elements, box-shadow is preferred, while drop-shadow is essential for non-rectangular shapes like PNG images with transparency.
The inset keyword fundamentally changes where the shadow is rendered, placing it inside the element rather than outside. An inset shadow creates the visual impression that the element is pressed into or carved out of the page surface. The offset values still work the same way, but their visual effect is reversed: a positive vertical offset creates a shadow at the top of the element interior, making it appear lit from below. Inset shadows are commonly used for input fields to create a recessed appearance, toggle switches to show pressed states, and neumorphic design patterns. You can combine inset and regular shadows on the same element by listing them comma-separated, creating complex depth effects.
Realistic depth effects mimic how light and shadow behave in the physical world. For a subtle elevation like a card, use small offsets (0-2px vertical), moderate blur (6-12px), and low opacity (10-15%). For medium elevation like dropdowns, increase the offset (4-8px vertical), blur (16-24px), and keep opacity moderate (15-20%). For high elevation like modals, use larger offsets (12-24px vertical), extensive blur (32-48px), and combine with a slight negative spread to prevent the shadow from appearing too large. Google Material Design popularized this approach with defined elevation levels. The key insight is that as elevation increases, shadows become larger, softer, and slightly less opaque, matching how ambient occlusion works in real lighting scenarios.
Yes, box-shadow is animatable with CSS transitions and keyframe animations, but there are important performance considerations. Adding transition: box-shadow 0.3s ease allows smooth shadow changes on hover or state changes. However, animating box-shadow can be expensive because it triggers repaints on every frame. A performant alternative is to create a pseudo-element with the target shadow, position it behind the element, and animate its opacity instead. This way the browser only needs to composite the opacity change rather than recalculating the shadow geometry each frame. For simple hover effects on a small number of elements, direct box-shadow animation is fine. For complex animations or many elements, the pseudo-element technique is strongly recommended.
Design tools like Figma, Sketch, and Adobe XD use slightly different shadow models than CSS. Figma exports shadows with X offset, Y offset, blur, and spread that map directly to CSS box-shadow values. However, Figma uses a different blur algorithm, so a 10px blur in Figma may look slightly different in the browser. Sketch shadows also map closely but may require opacity adjustment. Adobe XD uses distance and angle instead of X/Y offsets, requiring trigonometric conversion: X = distance times cosine of angle, Y = distance times sine of angle. When copying shadows from design tools, always verify the result in a browser. Color values may also differ between tools, especially regarding alpha channel handling and color space interpretation.
Educational Note: This calculator is provided for educational and informational purposes. Results are based on the formulas and inputs provided. Always verify important calculations independently. NovaCalculator processes calculator inputs client-side; optional analytics follow visitor consent settings. ยฉ 2024โ€“2026 NovaCalculator.

Share this calculator

Formula

box-shadow: [inset] h-offset v-offset blur spread color

The box-shadow property accepts an optional inset keyword, horizontal offset, vertical offset, blur radius, spread radius, and color. Positive horizontal values move the shadow right, positive vertical values move it down. Blur softens edges and spread expands or contracts the shadow.

Worked Examples

Example 1: Material Design Card Shadow

Problem: Create a subtle shadow for a card component that looks elevated, similar to Material Design elevation level 2.

Solution: Use no horizontal offset, 4px vertical offset, 12px blur, and 0 spread with 15% opacity black.\nbox-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.15);\nThe zero horizontal offset keeps the shadow centered.\nThe 4px vertical offset simulates a top-down light source.\n12px blur creates a soft, natural gradient at the edges.

Result: CSS: box-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.15); โ€” clean elevated card shadow.

Example 2: Floating Button Shadow

Problem: Create a prominent shadow for a floating action button that appears to hover above the page with significant depth.

Solution: Use 0px horizontal, 10px vertical, 25px blur, and -5px spread with 20% opacity.\nbox-shadow: 0px 10px 25px -5px rgba(0, 0, 0, 0.20);\nThe -5px spread prevents the shadow from extending beyond the button width.\nThe 25px blur creates a very soft, diffused shadow.\n10px vertical offset implies the button is significantly elevated.

Result: CSS: box-shadow: 0px 10px 25px -5px rgba(0, 0, 0, 0.20); โ€” dramatic floating shadow.

Frequently Asked Questions

How do blur and spread values affect the shadow appearance?

Blur and spread work together to define the shadow shape and softness. The blur radius creates a Gaussian blur effect, where a value of zero produces a sharp-edged shadow identical to the element shape. Larger blur values make the shadow progressively softer and more diffused. The spread radius expands (positive values) or contracts (negative values) the shadow before the blur is applied. A positive spread makes the shadow larger than the element, useful for creating glow effects. A negative spread makes the shadow smaller, which when combined with a vertical offset and large blur, creates realistic elevated shadows. Understanding these two properties independently gives you precise control over shadow aesthetics.

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

Box-shadow and the drop-shadow filter produce similar visual effects but work fundamentally differently. Box-shadow applies a shadow to the rectangular box model of an element, meaning it always creates a rectangular shadow regardless of the element content shape. The drop-shadow CSS filter, on the other hand, respects the alpha channel of the element, creating shadows that follow the actual shape of transparent images or text. Box-shadow also supports the spread radius and inset keyword, which drop-shadow does not. Performance-wise, box-shadow is generally faster because it does not require compositing. For rectangular elements, box-shadow is preferred, while drop-shadow is essential for non-rectangular shapes like PNG images with transparency.

How does the inset keyword change box-shadow behavior?

The inset keyword fundamentally changes where the shadow is rendered, placing it inside the element rather than outside. An inset shadow creates the visual impression that the element is pressed into or carved out of the page surface. The offset values still work the same way, but their visual effect is reversed: a positive vertical offset creates a shadow at the top of the element interior, making it appear lit from below. Inset shadows are commonly used for input fields to create a recessed appearance, toggle switches to show pressed states, and neumorphic design patterns. You can combine inset and regular shadows on the same element by listing them comma-separated, creating complex depth effects.

What shadow values create the most realistic depth effects?

Realistic depth effects mimic how light and shadow behave in the physical world. For a subtle elevation like a card, use small offsets (0-2px vertical), moderate blur (6-12px), and low opacity (10-15%). For medium elevation like dropdowns, increase the offset (4-8px vertical), blur (16-24px), and keep opacity moderate (15-20%). For high elevation like modals, use larger offsets (12-24px vertical), extensive blur (32-48px), and combine with a slight negative spread to prevent the shadow from appearing too large. Google Material Design popularized this approach with defined elevation levels. The key insight is that as elevation increases, shadows become larger, softer, and slightly less opaque, matching how ambient occlusion works in real lighting scenarios.

Can I animate box-shadow with CSS transitions?

Yes, box-shadow is animatable with CSS transitions and keyframe animations, but there are important performance considerations. Adding transition: box-shadow 0.3s ease allows smooth shadow changes on hover or state changes. However, animating box-shadow can be expensive because it triggers repaints on every frame. A performant alternative is to create a pseudo-element with the target shadow, position it behind the element, and animate its opacity instead. This way the browser only needs to composite the opacity change rather than recalculating the shadow geometry each frame. For simple hover effects on a small number of elements, direct box-shadow animation is fine. For complex animations or many elements, the pseudo-element technique is strongly recommended.

How do I convert box-shadow values between design tools and CSS?

Design tools like Figma, Sketch, and Adobe XD use slightly different shadow models than CSS. Figma exports shadows with X offset, Y offset, blur, and spread that map directly to CSS box-shadow values. However, Figma uses a different blur algorithm, so a 10px blur in Figma may look slightly different in the browser. Sketch shadows also map closely but may require opacity adjustment. Adobe XD uses distance and angle instead of X/Y offsets, requiring trigonometric conversion: X = distance times cosine of angle, Y = distance times sine of angle. When copying shadows from design tools, always verify the result in a browser. Color values may also differ between tools, especially regarding alpha channel handling and color space interpretation.

References

Reviewed by Daniel Agrici, Founder & Lead Developer ยท Editorial policy