# Success State Button

> A submit button that turns green and draws a checkmark when its data-state is set to done.

- Category: [CSS Buttons](https://copy-css.com/category/buttons)
- Tags: checkmark, done, submitted, feedback, confirmation
- Live preview: https://copy-css.com/snippets/success-state-button
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<button class="btn-success" type="button">Submit</button>
<button class="btn-success" type="button" data-state="done">
  <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>
  Submitted
</button>
```

## CSS

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

.btn-success svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 24;
}

.btn-success[data-state="done"] {
  background: #15803d;
  animation: btn-success-pop 0.35s ease;
}

.btn-success[data-state="done"] svg {
  animation: btn-success-draw 0.4s 0.15s ease-out backwards;
}

.btn-success:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 3px;
}

@keyframes btn-success-pop {
  50% { transform: scale(1.06); }
}

@keyframes btn-success-draw {
  from { stroke-dashoffset: 24; }
}

@media (prefers-reduced-motion: reduce) {
  .btn-success[data-state="done"],
  .btn-success[data-state="done"] svg { animation: none; }
}
```

## Notes

- This CSS Success State Button is 51 lines of pure CSS (1.0 KB) with no JavaScript and no dependencies. It uses keyframe animations, transitions, transforms and Flexbox.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
