# Loading Button

> A button with a built-in spinner. Add the is-loading class while a request runs.

- Category: [CSS Buttons](https://copy-css.com/category/buttons)
- Tags: loading, spinner, state, submit, form
- Live preview: https://copy-css.com/snippets/loading-button
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<button class="btn-loading is-loading">Saving…</button>
```

## CSS

```css
.btn-loading {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 26px;
  border: 0;
  border-radius: 12px;
  background: #2563eb;
  color: #fff;
  font: 600 16px/1 system-ui, sans-serif;
  cursor: pointer;
}

.btn-loading.is-loading {
  cursor: progress;
  opacity: 0.9;
}

.btn-loading.is-loading::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .btn-loading.is-loading::before {
    animation-duration: 2s;
  }
}
```

## Notes

- This CSS Loading Button is 37 lines of pure CSS (0.7 KB) with no JavaScript and no dependencies. It uses keyframe animations, transforms, Flexbox and reduced-motion support.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
