Squiggles flow clockwise along each edge of a box and fade out into plain rounded corners. Each side is a strip masked by a tiny inline SVG wave, and the mask slides exactly one wave per loop.
Also known as: css wavy border, squiggly border css, wave border animation, animated wavy line border.
<div class="bdr-squiggly-border"> <span class="bdr-squiggly-border-edge" aria-hidden="true"></span> <span class="bdr-squiggly-border-edge" aria-hidden="true"></span> <span class="bdr-squiggly-border-edge" aria-hidden="true"></span> <span class="bdr-squiggly-border-edge" aria-hidden="true"></span> <span class="bdr-squiggly-border-text"><i></i>On air</span> </div>
.bdr-squiggly-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;
--wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 10'%3E%3Cpath d='M0 5Q5 .6 10 5T20 5' fill='none' stroke='%23000' stroke-width='2'/%3E%3C/svg%3E");
--fade: linear-gradient(90deg, transparent 0.6em, #000 2.2em, #000 calc(100% - 2.2em), transparent calc(100% - 0.6em));
background: color-mix(in srgb, var(--c) 5%, transparent);
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 22%, transparent);
}
.bdr-squiggly-border-edge {
--len: 15em;
--off: 4.25em;
position: absolute;
top: 50%;
left: 50%;
width: var(--len);
height: 0.7em;
margin: -0.35em 0 0 calc(var(--len) / -2);
background: var(--c);
filter: drop-shadow(0 0 0.15em color-mix(in srgb, var(--c) 50%, transparent));
transform: rotate(var(--r, 0deg)) translateY(calc(var(--off) * -1));
-webkit-mask: var(--wave) 0 0 / 1.4em 100% repeat-x, var(--fade);
-webkit-mask-composite: source-in;
mask: var(--wave) 0 0 / 1.4em 100% repeat-x, var(--fade);
mask-composite: intersect;
animation: bdr-squiggly-border-flow 1.1s linear infinite;
}
.bdr-squiggly-border-edge:nth-child(2) { --len: 8.5em; --off: 7.5em; --r: 90deg; }
.bdr-squiggly-border-edge:nth-child(3) { --r: 180deg; }
.bdr-squiggly-border-edge:nth-child(4) { --len: 8.5em; --off: 7.5em; --r: 270deg; }
.bdr-squiggly-border-text {
display: inline-flex;
align-items: center;
gap: 0.45em;
letter-spacing: 0.02em;
}
.bdr-squiggly-border-text i {
width: 0.5em;
height: 0.5em;
border-radius: 50%;
background: var(--c);
box-shadow: 0 0 0 0.2em color-mix(in srgb, var(--c) 20%, transparent);
animation: bdr-squiggly-border-live 1.1s cubic-bezier(0.45, 0, 0.55, 1) infinite alternate;
}
@keyframes bdr-squiggly-border-flow {
from { -webkit-mask-position: 0 0, 0 0; mask-position: 0 0, 0 0; }
to { -webkit-mask-position: 1.4em 0, 0 0; mask-position: 1.4em 0, 0 0; }
}
@keyframes bdr-squiggly-border-live {
to { box-shadow: 0 0 0 0.32em color-mix(in srgb, var(--c) 8%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
.bdr-squiggly-border-edge,
.bdr-squiggly-border-text i { animation: none; }
}
@media (prefers-reduced-motion: reduce) {
.bdr-squiggly-border, .bdr-squiggly-border *, .bdr-squiggly-border::before, .bdr-squiggly-border::after, .bdr-squiggly-border *::before, .bdr-squiggly-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.