AI CSS Animations

Starburst Badge Button

A round sale badge with a spiky starburst edge that turns slowly and a dashed inner ring turning the other way, while the tilted label holds still. The burst is a clip-path polygon on a pseudo.

Also known as: sale badge css, starburst shape css, discount badge button.

HTML

<button class="btn-starburst-badge" type="button"><span class="btn-starburst-badge-text"><small>Save</small>50%</span></button>

CSS

.btn-starburst-badge {
  --c: var(--btn-color, #3b82f6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.75em 1.6em;
  border: 0;
  border-radius: 0.6em;
  font: 600 var(--btn-size, 18px)/1.1 system-ui, sans-serif;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  isolation: isolate;
  width: 6.6em;
  height: 6.6em;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);}
.btn-starburst-badge::before,
.btn-starburst-badge::after {
  content: "";
  position: absolute;
  z-index: -1;
  animation: btn-starburst-badge-turn 16s linear infinite;
}
.btn-starburst-badge::before {
  inset: 0;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--c) 80%, #fff), var(--c) 60%);
  clip-path: polygon(50.00% 0.00%, 57.47% 7.65%, 67.10% 3.02%, 71.50% 12.76%, 82.14% 11.70%, 82.94% 22.36%, 93.30% 25.00%, 90.41% 35.29%, 99.24% 41.32%, 93.00% 50.00%, 99.24% 58.68%, 90.41% 64.71%, 93.30% 75.00%, 82.94% 77.64%, 82.14% 88.30%, 71.50% 87.24%, 67.10% 96.98%, 57.47% 92.35%, 50.00% 100.00%, 42.53% 92.35%, 32.90% 96.98%, 28.50% 87.24%, 17.86% 88.30%, 17.06% 77.64%, 6.70% 75.00%, 9.59% 64.71%, 0.76% 58.68%, 7.00% 50.00%, 0.76% 41.32%, 9.59% 35.29%, 6.70% 25.00%, 17.06% 22.36%, 17.86% 11.70%, 28.50% 12.76%, 32.90% 3.02%, 42.53% 7.65%);
}
.btn-starburst-badge::after {
  inset: 0.85em;
  border: 2px dashed rgba(255, 255, 255, 0.65);
  border-radius: 50%;
  animation-duration: 24s;
  animation-direction: reverse;
}
.btn-starburst-badge-text {
  display: grid;
  font-size: 1.45em;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 0.06em 0 color-mix(in srgb, var(--c) 55%, #000);
  transform: rotate(-10deg);
}
.btn-starburst-badge-text small {
  font-size: 0.42em;
  font-weight: 800;
  letter-spacing: 0.2em;
  margin-right: -0.2em;
  text-transform: uppercase;
}
.btn-starburst-badge:is(:hover, :focus-visible) { transform: scale(1.06) rotate(-4deg); }
.btn-starburst-badge:active { transform: scale(0.94); }
@keyframes btn-starburst-badge-turn {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .btn-starburst-badge, .btn-starburst-badge *, .btn-starburst-badge::before, .btn-starburst-badge::after, .btn-starburst-badge *::before, .btn-starburst-badge *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --btn-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --btn-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 18px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar buttons