Glassmorphic Button Template
Create a beautiful "frosted glass" effect with this modern glassmorphic button.
This design style is perfect for interfaces that sit on top of colorful backgrounds, adding depth and a sense of layered perspective to your page.
About the Glassmorphic Button
Glassmorphism is a design trend characterized by transparency, background blur, and a subtle border that makes an element look like it's made of frosted glass. This effect is useful for creating a visual hierarchy, making foreground elements distinct from the background while still allowing the background to show through. For the effect to be noticeable, it needs to be placed on a colorful or detailed background, such as a gradient or a photo.
Features
- Frosted Glass Effect: The main effect is achieved with the
backdrop-filterproperty, which blurs whatever is behind the element. - Subtle Transparency: A semi-transparent
background-colorallows the background to show through slightly. - Clean Border: A light, thin border helps to define the button's edges and enhances the "glass" look.
- Accessible Focus State: Includes a standard high-contrast outline for keyboard navigation.
Code Breakdown
The glassmorphic effect is achieved with two CSS properties. First, background-color is set to a color with an alpha channel (e.g., rgba(255, 255, 255, 0.2)) to make the button partially transparent. Second, the backdrop-filter property is set to blur(), which applies a blur to everything visible behind the button. The container in this template uses a CSS gradient, but this can easily be swapped for a background-image to achieve the effect over a photograph.
Code
Here is the complete code for the glassmorphic button.