A soft halo in the accent color breathes around a light box, the outer glow most cards and inputs want. The halo is a shadow on a pseudo-element, so only its opacity animates.
Also known as: glowing border css, box shadow glow effect, css outer glow effect.
<div class="bdr-glowing-border">Glowing border</div>
.bdr-glowing-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;
background: color-mix(in srgb, var(--c) 5%, #fff);
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 45%, transparent);
color: color-mix(in srgb, var(--c) 45%, #111827);
}
.bdr-glowing-border::before {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
box-shadow: 0 0 0.8em 0.05em var(--c), 0 0 1.8em color-mix(in srgb, var(--c) 35%, transparent);
pointer-events: none;
animation: bdr-glowing-border-breathe 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes bdr-glowing-border-breathe {
50% { opacity: 0.5; }
}
@media (prefers-reduced-motion: reduce) {
.bdr-glowing-border, .bdr-glowing-border *, .bdr-glowing-border::before, .bdr-glowing-border::after, .bdr-glowing-border *::before, .bdr-glowing-border *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}The same effect using Tailwind utility classes. No custom CSS or config needed.
<div class="relative grid h-[8.5em] w-[15em] place-items-center rounded-2xl bg-white font-semibold text-blue-950 ring-1 ring-inset ring-blue-500/50"> <span class="pointer-events-none absolute inset-0 animate-pulse rounded-[inherit] shadow-[0_0_0.8em_0.05em_#3b82f6,0_0_1.8em_rgb(59_130_246/0.35)]"></span> Glowing border </div>
--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.