July 21st, 2024

So you think you know box shadows?

This article explores creative uses of box shadows in web design, covering basics, layering for effects, simulating 3D, and performance considerations. It showcases innovative applications with code snippets and demos.

Read original articleLink Icon
ExplorationAppreciationCritique
So you think you know box shadows?

This article delves into the creative and unconventional use of box shadows in web design. It explains the basics of box shadows as a form of drop filter and their application in adding depth to UI elements. The piece explores pushing the boundaries of box shadows by layering multiple shadows to create unique visual effects. It also discusses experimenting with box shadows to simulate 3D effects, such as creating bouncing balls and projecting points onto surfaces. The author shares code snippets and visual demos to showcase these innovative uses of box shadows, including rendering thousands of shadows in real-time and mapping pixels from images to create dynamic visual effects. The article concludes by highlighting the performance implications of using complex box shadow configurations and the potential for further exploration in creating interactive and visually engaging web experiences.

AI: What people are saying
The article on creative uses of box shadows in web design generated a variety of comments:
  • Discussions on technical aspects, such as transparency affecting GPU performance and the use of depth buffers.
  • Appreciation for the article's exploration and innovative applications, with some users sharing related projects and experiences.
  • Suggestions for improvements and additional features, like adding RSS support to the blog and fixing grammatical errors.
  • Comparisons to other web design techniques and tools, including references to canvas and other shadow-related projects.
  • General praise for the article's content and its impact on readers' understanding of web design.
Link Icon 32 comments
By @sunnyps - 7 months
> However, using a transparent color significantly slowed down the number that can be drawn too which doesn't make as much sense to me. I'd imagine that with hardware today transparency should be somewhat free.

That's because transparency limits how you can batch draws on the GPU. With opaque draws, you can use the depth buffer and draw in any order you like e.g. maximizing batching. With transparency, you need to draw things in the right order for blending to work (painters order).

By @paulirish - 7 months
Seriously fun exploration.

> Layering. That is an important word.

Layering is also the key to the (silly but also sometimes good-looking) effects from my text shadow project from 14yrs ago: https://paulirish.github.io/mothereffingtextshadow/

By @ctippett - 7 months
I'm embarrassed to admit it took until the final paragraph before realising that 'gypity' is a reference to Chat GPT.
By @recursive - 7 months
I'm totally down for some good old fashioned impractical hacking. But just remember, we already have canvas, which can do all this easier, faster, and better.
By @tracker1 - 6 months
Looking at the music visualizations was definitely cool. Really miss the old winamp days when you could play music and just run the visualizer full screen. I wish that streaming audio players did this today.
By @butz - 7 months
But at the end of the day Firefox and Chrome are still rendering 1px box-shadow differently at 150% browser zoom. Best hopes for Baseline 2025.
By @yesimahuman - 7 months
> It also turns out that some smart people figured out maths hacks to draw rounded boxes for super cheap which UI peeps love because with this hack boxes can be so round as to appear as circles

Any references to learn more about these hacks?

By @fitsumbelay - 7 months
My kind of hackin' Almost like an antichrist to the Josh Comeau posts I've read on the topic https://www.google.com/search?q=josh+comeau+shadows
By @efilife - 7 months
A great, possibly the greatest article I read this year ended with "your welcome" instead of "you're". Fix asap! Or maybe I didn't get the joke, that's a possibility
By @kristopolous - 7 months
For the past 30 years I got good at programming but never really did graphics because I didn't like games. I now view it as a massive oversight and have been trying to catch up for over a year.

So hard.

By @coding123 - 7 months
As usual, when will we get Quake or Doom ray-trace rendered using box shadow?
By @adrianpluis - 7 months
Well done with writing your experience.
By @SuaveSteve - 6 months
>So you think you know ((CSS FEATURE))?

Why would I know it? It's CSS!

By @anymouse123456 - 6 months
I love this kind of content. It reminds me of the early aughts when folks were doing a lot more of this stuff for fun.
By @ulf-77723 - 7 months
Really great work, especially the music synced animation - could as well also be projected in an electro club
By @winrid - 7 months
This discussion around adding shadows to window boarders in imgui is also interesting: https://github.com/ocornut/imgui/issues/1329
By @develatio - 7 months
dgerrells, please add RSS support to your blog!
By @akira2501 - 7 months
Instead of animating the color balls to music, it'd be nice if my manipulations of the color balls _created_ music.
By @cchance - 7 months
He said it might melt your processor... but on a macbook m3 in arc runs great, like every one of those was amazing.
By @merceranthony78 - 7 months
Amazing. Is it possible to tell how much lag these would cause if used on a production website?
By @theturtle32 - 7 months
THIS IS ABSOLUTELY EPIC, AND MY FAVORITE KIND OF WEB TECH DEEP DIVE! <3 <3 <3
By @nimish - 7 months
Full color RGB flip dot display!
By @mediumsmart - 6 months
I know not to use them without much thinking involved.
By @pfannkuchen - 7 months
Solid watch for rolling rocks energy.
By @ThatUnknownDude - 6 months
Ok this is really cool
By @tompetry - 7 months
This was awesome