Tony's Collections
Tony's Bundles
tony /
Shimmer Patterns
Shimmer Patterns
Use simple classes to build shimmer UI Skeletons.
Setup
- Add Shimmers to your page - see instructions under the files tab.
- Create your shimmer html.
- Wrap everything in the
.shimmer
class. - Use
.rect
for a rectangle. - Use
.circle
for a circle. - Use width utility classes to set widths.
- Customise colors and border radius with css variables.
- Wrap everything in the
Example
<div class="shimmer">
<div class="rect"></div>
<div class="rect width-.75"></div>
<div class="rect width-.5"></div>
<div class="rect width-.25"></div>
</div>
Output
<div class="shimmer">
<div class="circle lg"></div>
<div class="rect width-.75"></div>
<div class="rect width-.5"></div>
<div class="rect width-.25"></div>
</div>
Output
Code
.shimmer {
width: 100%
}
.shimmer > * {
margin: var(--shimmer-block-default-margin, 0 0 10px 0);
}
.shimmer .circle,
.shimmer .rect {
background: var(--shimmer-block-color-from, #f6f7f8);
background-image: linear-gradient(to right, var(--shimmer-block-color-from, #f6f7f8) 0%, var(--color-to, #edeef1) 20%, var(--shimmer-block-color-from, #f6f7f8) 40%, var(--shimmer-block-color-to, #f6f7f8) 100%);
background-repeat: repeat-y;
background-size: 100% 50px;
position: relative;
animation-duration: 1s;
animation-fill-mode: forwards;
animation-iteration-count: infinite;
animation-name: placeholderShimmer;
animation-timing-function: linear;
}
.shimmer .rect {
height: var(--shimmer-block-height, 20px);
border-radius: var(--shimmer-block-border-radius, 10px)
}
.shimmer .circle {
border-radius: 100000px;
width: calc( var(--shimmer-block-height, 20px) * 3);
height: calc( var(--shimmer-block-height, 20px) * 3);
animation-duration: .8s;
animation-name: placeholderShimmerCircle;
}
.shimmer .circle.xs {
width: var(--shimmer-block-height, 20px);
height: var(--shimmer-block-height, 20px);
}
.shimmer .circle.sm {
width: calc( var(--shimmer-block-height, 20px) * 2);
height: calc( var(--shimmer-block-height, 20px) * 2);
}
.shimmer .circle.md {
width: calc( var(--shimmer-block-height, 20px) * 4);
height: calc( var(--shimmer-block-height, 20px) * 4);
}
.shimmer .circle.lg {
width: calc( var(--shimmer-block-height, 20px) * 5);
height: calc( var(--shimmer-block-height, 20px) * 5);
}
.shimmer .centered {
margin-left: auto;
margin-right: auto;
}
.shimmer .width-\.25 {
width: 25%;
}
.shimmer .width-\.5 {
width: 50%;
}
.shimmer .width-\.75 {
width: 75%;
}
@keyframes placeholderShimmer {
0% {
background-position: -468px 0;
}
100% {
background-position: 468px 0;
}
}
@keyframes placeholderShimmerCircle {
0% {
background-position: -80px 0;
}
100% {
background-position: 80px 0;
}
}
Add this to the <head> of your page