With shadows being the primary method to add depth to elements on a light background, lights add depth and separation to elements on dark mode.
This effect is inspired by a post by @fffabs on Twitter. Not a single line of code was written during the making of this interaction.
PS: This is based on mouse interactions and is best suited for desktops and tablets with trackpads/mouse.
When the rebel in me saw comments that it would be hard to implement, I was like, "YEAH, let's do it!". While working on it, what would be better than making it without even writing any code?
Thanks to Webflow, I was able to do it pretty easily and I'm sharing these steps with the rest of the community for anyone to use, learn and improve upon.
The benefits of recreating in Figma allows for better planning for layers in Webflow while understanding the limitations.
When working for the web, some of the things to consider are how objects are stacked, how they need to be adaptable with dynamic text and how masking works differently.
The border block needs to be placed under the content block in order to independently control it, and use that as a "mask" for the second border color that interacts with mouse position.
To place them at the same position stacked on top of each other, the content class is used to set up the size with padding. The border block uses position absolute, and the 1px margin across the content block makes the border visible.
There are multiple ways of achieving this, including transform sizing, but the biggest benefit to approach, is to get a consistent border across all corners regardless of the size.
The other benefit is, masking.
Clipping masks are an option, but using the standard overflow hidden property allows for easier sizing for dynamic buttons.
Often overlooked, using mouse interactions is one of the most fun ways to visually create interactions that are often hard to create, even for some seasoned front-end developers.
These interactions are set up on the top container layer, as that registers the mouse position and we can control multiple objects using the same interactions panel.
Just like with borders, in order to create the glow effect, we have to create more layers. However, CSS does not allow to use the overflow property for masking the glow effect, therefore we have to make sure to limit how far the glow layers can go.
These interactions are set up on the top container layer, as it registers the mouse position and we can control multiple objects using the same interactions panel.
Finally, we have to add the hover interactions for both mouse over and mouse out to return our elements to their starting position.
In this case, simple opacity was used to fade in and out the glowing border and glowing light (shadow).
It was fun to work on a post I found on Twitter. I hope you found this tutorial helpful. Please feel free to share it with others. I am available for freelance Web/App Design and Webflow Development projects.
I get easily distracted from working on my own portfolio website but you can follow me on Twitter to stay in touch where I tweet about product design and front-end development.