Skip to content
English

How it works

A 52×52 SVG that plays on a timeline: a soft aura opens, a solid disc in the status colour springs in, the check or cross is drawn across it in the contrasting ink (white on light, near-black on dark), then a ripple ring spreads out and fades (a shake on failure). Strokes use pathLength="1" and a dashoffset from 1 to 0, so no lengths are measured. Every delay is a fraction of one duration value. Default styles are the end state, so reduced motion simply shows the result.

Use it for

  • Result pages or dialogs after key actions such as payment, checkout or submitting a form.
  • Failures that need a clear signal (variant="error").
  • Moments that deserve some ceremony without adding an animation library.

Look elsewhere when

  • Small status icons on every list row: use a static icon.
  • Frequent light feedback such as "copied": use a toast or the button's own state.
  • While the result is still pending: show a loading state first.

Usage

import { useState } from 'react'
import { SuccessCheck } from './SuccessCheck.jsx'

export function PayResult({ ok }) {
  const [play, setPlay] = useState(0)
  return (
    <div style={{ textAlign: 'center' }}>
      <SuccessCheck
        size={72}
        variant={ok ? 'success' : 'error'}
        playKey={play}
        label={ok ? 'Payment received' : 'Payment failed'}
        onDone={() => console.log('Animation finished')}
      />
      <h3>{ok ? 'Payment received' : 'Payment failed'}</h3>
      <button onClick={() => setPlay((n) => n + 1)}>Play again</button>
    </div>
  )
}

Props

PropTypeDefaultWhat it does
sizenumber72Icon side length in px; line widths scale with it.
variant'success' | 'error' | 'accent''success'success: green disc with a check; error: red disc with a cross and a shake; accent: accent disc with a check.
durationnumber900Total animation time in ms; phases scale in proportion.
playKeystring | number—Replays the animation whenever it changes.
onDone() => void—Called when the animation ends; immediately under reduced motion.
labelstring'Success' / 'Failed' / 'Done' by variantAccessible name (aria-label of the role="img" root). Pass the concrete result, such as "Payment received".
...restHTMLAttributes<HTMLSpanElement>—Other attributes, such as className and style, go to the root element.

Accessibility

  • The root is role="img" with an aria-label that reads the result; the SVG itself is aria-hidden.
  • The icon is only emphasis: show the result as text too, in a live region if needed.
  • With reduced motion nothing animates, the end state shows, and onDone fires at once.
  • Shape (check or cross) separates the outcomes as well as color.

Motion

900ms by default: aura 50% (scale 0.55 to 1), disc 45% from 5% on the spring curve (slight overshoot), check 40% from 36%, ripple 50% from 50% (scale to 1.75 while fading). The failure shake runs ease-in-out from 62%.

Add it to your project

Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the component next to your own.

SuccessCheck.jsxsuccess-check.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Feedback
Confetti burst comes with Pro. Its preview shows once you unlock it.