Gradient stat tile
CSS gradient stat tile: a big number over a label on a three-stop gradient. Hover slides the colors and sweeps a light sheen across.
Each tile has a linear-gradient background with three stops taken from custom properties and background-size: 160% 100%, which leaves spare gradient to move. On hover, background-position goes to 100% 0 and the transition slides the colors across. The sheen is an ::after layer, a narrow translucent white band in a transparent gradient, that moves from translateX(-100%) to 100% on hover and is clipped by overflow: hidden. The second tile only overrides the three color variables.
snippet.html26 lines
<div class="gst" role="group" aria-label="Spec tiles">
<div class="gst__tile gst__tile--a"><strong>6.67″</strong><span>OLED Display</span></div>
<div class="gst__tile gst__tile--b"><strong>512</strong><span>GB Storage</span></div>
</div>
<style>
.gst { display: flex; gap: 14px; font-family: "Avenir Next", "Helvetica Neue", ui-sans-serif, system-ui, sans-serif; }
.gst__tile {
--gst-a: #7a1fc4; --gst-b: #b44fe0; --gst-c: #1ea58e;
position: relative; overflow: hidden;
display: flex; flex-direction: column; align-items: center; justify-content: center;
width: 190px; height: 130px;
border-radius: 12px; color: #fff; text-align: center;
background: linear-gradient(120deg, var(--gst-a) 0%, var(--gst-b) 45%, var(--gst-c) 100%);
transition: transform 0.3s ease, background-position 0.6s ease;
background-size: 160% 100%;
}
.gst__tile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 40%, rgb(255 255 255 / 0.16) 50%, transparent 60%); transform: translateX(-100%); transition: transform 0.7s ease; }
.gst__tile:hover { transform: translateY(-3px); background-position: 100% 0; }
.gst__tile:hover::after { transform: translateX(100%); }
.gst__tile--b { --gst-a: #168f7a; --gst-b: #3b1a7a; --gst-c: #9a3ee0; }
.gst__tile strong { position: relative; font-size: 2.5rem; font-weight: 600; line-height: 1; letter-spacing: -0.03em; }
.gst__tile span { position: relative; margin-top: 0.4rem; font-size: 0.8125rem; opacity: 0.85; }
@media (max-width: 460px) { .gst { flex-direction: column; } .gst__tile { width: 100%; } }
@media (prefers-reduced-motion: reduce) { .gst__tile, .gst__tile::after { transition: none; } .gst__tile:hover { transform: none; } }
</style>