Animated Checkmark
成功勾选动画
A checkmark draws itself to confirm that an action has completed successfully.
Where to use it
Confirm a completed save, submission, or upload alongside a status message. Play the stroke once the operation has succeeded and keep the written result visible after the stroke finishes.
Practical example
After a volunteer signs up for a shift, a checkmark draws beside “Saturday shift booked” once the booking is confirmed. The message remains on screen long enough to verify the time.
AI prompt
Add Animated Checkmark to the successful state of [target action]. Play a short stroke-drawing animation once the operation succeeds. Provide a readable success message and keep the mark decorative for screen readers. Show the complete mark immediately with reduced motion.
Example code
Save the standalone HTML as a file and open it in your browser. It uses the same code as the preview.
View HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Animated Checkmark</title>
<style>
:root {
color-scheme: dark;
--demo-bg: #171629;
--demo-ink: #f8f5ff;
--demo-accent: #b9a6ff;
--demo-muted: #bfbbd3;
font-family: system-ui, sans-serif;
color: var(--demo-ink);
background: var(--demo-bg);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
button, input { font: inherit; }
.demo {
display: grid;
place-items: center;
align-content: center;
min-height: 100vh;
padding: 14px;
overflow: hidden;
background: radial-gradient(ellipse at 50% 24%, #28233f, var(--demo-bg) 78%);
}
.demo-button {
border: 1px solid #ffffff3d;
border-radius: 7px;
background: #ffffff12;
color: var(--demo-ink);
padding: 6px 11px;
font-size: 12px;
cursor: pointer;
}
:focus-visible {
outline: 2px solid var(--demo-accent);
outline-offset: 3px;
}
.check-example { display: grid; justify-items: center; gap: 12px; }
.check-result {
display: flex;
align-items: center;
gap: 11px;
padding: 11px 16px 11px 11px;
border: 1px solid #35605a;
border-radius: 16px;
background: #1b3534;
color: #d7f9e9;
font-size: 13px;
font-weight: 650;
}
.check-badge {
display: grid;
place-items: center;
width: 39px;
height: 39px;
border-radius: 50%;
background: #a1f1ce;
color: #164737;
}
.checkmark { position: relative; width: 10px; height: 18px; transform: translateY(-2px) rotate(45deg); }
.checkmark::before, .checkmark::after {
position: absolute;
right: 0;
bottom: 0;
background: currentColor;
border-radius: 2px;
content: '';
}
.checkmark::before { width: 100%; height: 3px; transform-origin: left; }
.checkmark::after { width: 3px; height: 100%; transform-origin: bottom; }
[data-drawing] .checkmark::before { animation: draw-short 160ms ease-out both; }
[data-drawing] .checkmark::after { animation: draw-long 230ms 150ms ease-out both; }
@keyframes draw-short { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes draw-long { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) {
[data-drawing] .checkmark::before, [data-drawing] .checkmark::after { animation: none; }
[data-replay] { display: none; }
}
</style>
</head>
<body>
<main class="demo">
<div class="check-example">
<div class="check-result" role="status">
<span class="check-badge" aria-hidden="true"><span class="checkmark"></span></span>
<span>Changes saved</span>
</div>
<button class="demo-button" type="button" data-replay>Replay demo</button>
</div>
</main>
<script>
const result = document.querySelector('.check-result');
document.querySelector('[data-replay]').addEventListener('click', () => {
result.removeAttribute('data-drawing');
// Commit the reset before replaying the two strokes.
void result.offsetWidth;
result.setAttribute('data-drawing', '');
});
</script>
</body>
</html>Original example by UI Skills