Skip to content

Instantly share code, notes, and snippets.

@AkiraVoid
Last active April 27, 2024 08:55
Show Gist options
  • Save AkiraVoid/b46609d53640f7ac4a05cfd2f82538d8 to your computer and use it in GitHub Desktop.
Save AkiraVoid/b46609d53640f7ac4a05cfd2f82538d8 to your computer and use it in GitHub Desktop.
An implementation of Acrylic and Mica materials come from Microsoft's Fluent UI, using pure HTML & CSS

Acrylic & Mica in CSS

preview

An implementation of Acrylic and Mica materials come from Microsoft's Fluent UI, using pure HTML & CSS. The figures are guessed since Microsoft haven't yet published the details about these two materials.

Preview with CodePen

Warning

On Firefox, the CSS property backdrop-filter is only supported by version 103 or later, which is released in 2022. The -webkit- prefix is required for Safari.

References

<html>
<head>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div class="acrylic">
<!--Use svg with feTurbulence filter to create noise layer, see https://css-tricks.com/grainy-gradients/-->
<svg xmlns='http://www.w3.org/2000/svg'>
<filter id='noiseFilter'>
<feTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch' />
</filter>
<rect width='100%' height='100%' filter='url(#noiseFilter)' />
</svg>
<div class="content">Acrylic</div>
</div>
<div class="mica">
<div class="content">Mica</div>
</div>
</body>
</html>
body {
width: 100%;
height: 100%;
background: url("https://wallpapers.microsoft.design/images/feature-16.jpg")
center/cover;
position: relative;
}
.acrylic,
.mica {
position: absolute;
top: 50%;
transform: translateY(50%);
width: 400px;
height: 200px;
font-weight: 600;
box-sizing: border-box;
padding: 20px;
overflow: hidden;
}
.acrylic {
left: 200px;
/** Adjust the alpha channel to adjust the luminosity. 0.9 maps to 100% luminosity. Set to black to apply dark theme. */
background-color: rgba(255, 255, 255, 0.67);
backdrop-filter: blur(20px);
z-index: 1;
}
.acrylic > svg {
width: 400px;
height: 200px;
position: absolute;
top: 0;
left: 0;
opacity: 0.1;
z-index: 3;
}
.acrylic::before {
content: "";
width: 400px;
height: 200px;
position: absolute;
top: 0;
left: 0;
z-index: 1;
/** Adjust opacity to adjust Tint Opacity. 0.7 maps to 100% Tint Opacity. */
opacity: 0;
background-color: blue;
}
.acrylic > .content {
z-index: 4;
position: relative;
color: black;
}
.mica {
right: 200px;
/** Adjust the alpha channel to adjust the luminosity. 0.9 maps to 100% luminosity. Set to black to apply dark theme. */
background-color: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(40px);
z-index: 1;
border-radius: 12px;
}
.mica::before {
content: "";
content: "";
width: 400px;
height: 200px;
position: absolute;
top: 0;
left: 0;
z-index: 1;
/** Adjust opacity to adjust Tint Opacity. 0.7 maps to 100% Tint Opacity. */
opacity: 0.14;
background-color: blue;
}
.mica > .content {
position: relative;
color: black;
z-index: 3;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment