A thick, slowly turning gradient frame with a film grain texture over the whole box, the riso print look. The grain is an inline SVG turbulence filter blended with overlay, so there is no image file.
Also known as: noise gradient border css, grain texture border, grainy gradient css.
<div class="bdr-grainy-gradient-border"><svg class="bdr-grainy-gradient-border-grain" aria-hidden="true"><filter id="bdr-grainy-gradient-border-noise"><feTurbulence type="fractalNoise" baseFrequency="0.85" numOctaves="3" stitchTiles="stitch"/><feColorMatrix values="2.4 0 0 0 -0.7 2.4 0 0 0 -0.7 2.4 0 0 0 -0.7 0 0 0 0 1"/></filter><rect width="100%" height="100%" filter="url(#bdr-grainy-gradient-border-noise)"/></svg>Grainy gradient</div>
@property --bdr-grainy-gradient-border-a {
syntax: "<angle>";
inherits: false;
initial-value: 0deg;
}
.bdr-grainy-gradient-border {
--c: var(--bdr-color, #3b82f6);
font-size: var(--bdr-size, 16px);
position: relative;
display: grid;
place-items: center;
width: 15em;
height: 8.5em;
border-radius: 1em;
font-family: system-ui, sans-serif;
font-weight: 600;
--fill: color-mix(in srgb, var(--c) 10%, #0b0f19);
box-sizing: border-box;
isolation: isolate;
border: 0.34em solid transparent;
background:
linear-gradient(var(--fill), var(--fill)) padding-box,
conic-gradient(from var(--bdr-grainy-gradient-border-a), var(--c), color-mix(in oklch, var(--c), #f97316 75%), color-mix(in oklch, var(--c), #ec4899 80%), var(--c)) border-box;
color: #f8fafc;
animation: bdr-grainy-gradient-border-spin 8s linear infinite;
}
.bdr-grainy-gradient-border-grain {
position: absolute;
inset: -0.34em;
width: calc(100% + 0.68em);
height: calc(100% + 0.68em);
clip-path: inset(0 round 1em);
mix-blend-mode: overlay;
opacity: 0.5;
pointer-events: none;
}
@keyframes bdr-grainy-gradient-border-spin {
to { --bdr-grainy-gradient-border-a: 360deg; }
}
@media (prefers-reduced-motion: reduce) {
.bdr-grainy-gradient-border, .bdr-grainy-gradient-border *, .bdr-grainy-gradient-border::before, .bdr-grainy-gradient-border::after, .bdr-grainy-gradient-border *::before, .bdr-grainy-gradient-border *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--bdr-color on the element or a parent.
Currently previewing #3b82f6.--bdr-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 16px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.