JSFiddle - React, Tailwind, and code Playground
by Alexandru Gatea
HTML
<div class="dot single-category-1">
<span class="single">1</span>
</div>
<div class="dot single-category-2">
<span>15956</span>
</div>
<div class="dot single-category-3">
<span>178</span>
</div>
<div class="dot category-50">
<span >1784587</span>
</div>
<div class="dot category-50-10">
<span>3435</span>
</div>
<div class="dot category-25">
<span>1784587</span>
</div>
<div class="dot category-75">
<span>87</span>
</div>
<div class="dot category-10-5">
<span>187</span>
</div>
<div class="dot category-35-45">
<span>178457</span>
</div>
<div class="dot category-69">
<span>1784</span>
</div>
<div class="dot category-33-34">
<span>14587</span>
</div>
SCSS
body {
margin: 0;
padding: 100px;
box-sizing: border-box;
background: #ddd;
}
$default-color: #666;
$c1: #1DB58C;
$c2: #2E96E2;
$c3: #EA9A19;
.dot {
display: inline-block;
position: relative;
border-radius: 1000px;
margin: 50px;
cursor: pointer;
&:before,
&:after {
content: "";
display: block;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
transition: all 0.25s cubic-bezier(.5,.21,.18,1.59);
}
&:hover {
&:before{
width: calc(100% + 60px);
padding-bottom: calc(100% + 60px);
}
&:after{
width: calc(100% + 20px);
padding-bottom: calc(100% + 20px);
}
}
&:before {
z-index: 1;
width: calc(100% + 40px);
height: 0;
padding-bottom: calc(100% + 40px);
background: $default-color;
border-radius: 1000px;
box-shadow: 0px 0px 10px 3px rgba(0,0,0,0.15);
}
&:after {
z-index: 1;
width: calc(100% + 10px);
height: 0;
padding-bottom: calc(100% + 10px);
background: #fff;
border-radius: 1000px;
box-shadow: 0px 0px 6px 2px rgba(0,0,0,0.2);
}
span {
display: block;
padding: 4px;
font-size: 18px;
text-align: center;
font-family: "Trebuchet MS", "Arial", sans-serif;
font-weight: bold;
position: relative;
z-index: 3;
&.single {
padding: 12px;
}
}
}
.single-category-1:before {
background-color: $c1;
}
.single-category-2:before {
background-color: $c2;
}
.single-category-3:before {
background-color: $c3;
}
@for $i from 0 through 100 {
$pi: percentage($i/100);
.category-#{$i}:before {
background: conic-gradient($c1 $pi - 2%, $c2 $pi + 2% 98%, $c1);
}
@for $j from 0 through 100 {
$pj: percentage($j/100);
.category-#{$i}-#{$j}:before {
background: conic-gradient($c1 $pi - 2%, $c2 $pi + 2% $pi + $pj, $c3 $pi + $pj + 2% 98%, $c1);
}
}
}