Ever thought of adding lighting effects to your UI buttons? You can! Learn how to create directionally lit 3D buttons with CSS and just a little bit of JavaScript.
I’m not too sure how I stumbled into this one. But something led me to this tweet:
Has anyone done this directional lighting cursor interaction with CSS? pic.twitter.com/zLL7Sk6kW5 — Jed Bridges (@JedBridges) July 1, 2020
And, to me, that’s a challenge.
The button design is neat. But I didn’t want to do a direct copy. Instead, we decided to make a “Twitter” button. The idea is that we create an almost transparent button with a social icon on it. And then that social icon casts a shadow below. Moving our mouse across the button shines a light over it. Pressing the button pushes it onto the surface. Here’s the final result:
Directional Lighting 3D CSS Twitter Button 🐦
👉 https://t.co/qpfzEwUMey via @CodePen pic.twitter.com/zWfwtPaixo — Jhey 🐻🛠 (@jh3yy) January 30, 2021
In this article, we’re going to look at how you can make it too. The cool thing is, you can swap the icon out to whatever you want.
#css #javascript