Autosave Indicator
A copy-paste form states component in pure HTML, CSS & vanilla JS. Zero dependencies, framework-agnostic, MIT-licensed.
Form StatesHTMLJavaScriptCSSany framework
Saved
Copy into your project
HTML
<div class="nuda-fs2-autosave">
<label for="fs2-as-title" class="nuda-fs2-autosave__label">Document title</label>
<input id="fs2-as-title" class="nuda-fs2-autosave__input" type="text" value="Q3 roadmap draft">
<p class="nuda-fs2-autosave__status is-saved" role="status" aria-live="polite">
<span class="nuda-fs2-autosave__dot" aria-hidden="true"></span>
Saved
</p>
</div>
<!-- JS: on input, switch to .is-saving with text "Saving…", then after your
debounced save resolves switch to .is-saved with text "Saved". -->JavaScript
/* Autosave Indicator — debounced save → status swap. */
(function () {
var wrap = document.querySelector('.nuda-fs2-autosave');
if (!wrap) return;
var input = wrap.querySelector('.nuda-fs2-autosave__input');
var status = wrap.querySelector('.nuda-fs2-autosave__status');
var timer;
input.addEventListener('input', function () {
clearTimeout(timer);
status.classList.remove('is-saved');
status.classList.add('is-saving');
status.lastChild.textContent = 'Saving…';
timer = setTimeout(function () {
status.classList.remove('is-saving');
status.classList.add('is-saved');
status.lastChild.textContent = 'Saved';
}, 900);
});
})();CSS
.nuda-fs2-autosave {
width: 100%;
max-width: 260px;
display: flex;
flex-direction: column;
gap: 6px;
font-family: ui-sans-serif,system-ui,sans-serif;
}
.nuda-fs2-autosave__label {
font-size: 12px;
font-weight: 600;
color: #cfcfcf;
}
.nuda-fs2-autosave__input {
width: 100%;
height: 44px;
padding: 0 12px;
background: #161616;
border: 1px solid rgba(255,255,255,.12);
border-radius: 9px;
color: #fafafa;
font-size: 13px;
box-sizing: border-box;
transition: border-color .2s;
}
.nuda-fs2-autosave__input:focus-visible {
outline: 2px solid #e4ff54;
outline-offset: 2px;
border-color: #e4ff54;
}
.nuda-fs2-autosave__status {
margin: 0;
display: inline-flex;
align-items: center;
gap: 6px;
align-self: flex-start;
font-size: 11px;
color: #777;
transition: color .2s;
}
.nuda-fs2-autosave__dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: #777;
flex-shrink: 0;
transition: background .2s,transform .2s;
}
.nuda-fs2-autosave__status.is-saving {
color: #f5c451;
}
.nuda-fs2-autosave__status.is-saving .nuda-fs2-autosave__dot {
background: #f5c451;
animation: _nuda-fs2autosave-pulse 1s ease-in-out infinite;
}
.nuda-fs2-autosave__status.is-saved {
color: #7be08a;
}
.nuda-fs2-autosave__status.is-saved .nuda-fs2-autosave__dot {
background: #7be08a;
transform: scale(1);
}
@keyframes _nuda-fs2autosave-pulse {
0%,100% {
transform: scale(1);
opacity: 1;
}
50% {
transform: scale(1.4);
opacity: .5;
}
}
@media (prefers-reduced-motion:reduce) {
.nuda-fs2-autosave__status.is-saving .nuda-fs2-autosave__dot {
animation: none !important;
}
}
How to use Autosave Indicator
Paste the HTML where you need it and the CSS into a global stylesheet (or a <style> tag). Every class is prefixed nuda- so it never collides with Tailwind or your own styles. Tweak the CSS custom properties to match your design system.
Works in React, Vue, Svelte, Astro, Next.js, Nuxt, Laravel Blade, Django, Rails — or a single .html file. No npm install, no build step.