# Spinning Border Button

> A dark button with a beam of light that travels around its border, the look used for AI features.

- Category: [CSS Buttons](https://copy-css.com/category/buttons)
- Tags: conic-gradient, rotating, glow, dark, ai
- Live preview: https://copy-css.com/snippets/spinning-border-button
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<button class="btn-spin-border">Ask AI</button>
```

## CSS

```css
.btn-spin-border {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 14px 34px;
  border: 0;
  border-radius: 12px;
  background: #1e293b;
  color: #e2e8f0;
  font: 600 16px/1 system-ui, sans-serif;
  cursor: pointer;
}

/* A large rotating conic gradient, clipped by the button */
.btn-spin-border::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: -2;
  width: 200%;
  aspect-ratio: 1;
  background: conic-gradient(#0000 0 65%, #38bdf8, #a78bfa, #0000 95%);
  transform: translate(-50%, -50%);
  animation: btn-spin-border-rotate 3s linear infinite;
}

/* The inner fill covers everything except a 2px ring */
.btn-spin-border::after {
  content: "";
  position: absolute;
  inset: 2px;
  z-index: -1;
  border-radius: 10px;
  background: #0b1120;
}

.btn-spin-border:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 3px;
}

@keyframes btn-spin-border-rotate {
  to { transform: translate(-50%, -50%) rotate(1turn); }
}

@media (prefers-reduced-motion: reduce) {
  .btn-spin-border::before { animation: none; }
}
```

## Notes

- This CSS Spinning Border Button is 49 lines of pure CSS (1.1 KB) with no JavaScript and no dependencies. It uses keyframe animations, transforms, conic gradients and aspect-ratio.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
