Puneet Sharma - Frontend Developer & UI Engineer
Puneet Sharma
Frontend Dev & UI Engineer · 16+ yrs · pixel-perfect HTML, React & WordPress

10 Free Bootstrap 5 Snippets for the Forms and Tables That Actually Ship: Autosave Status, Hold-to-Confirm Delete & a Table That Handles Its Own Failures

0 Bootstrap 5 snippets for forms and tables: autosave status, hold-to-confirm delete, and a table that handles its own failures.
10 Free Bootstrap 5 Snippets for the Forms and Tables That Actually Ship: Autosave Status, Hold-to-Confirm Delete &  a Table That Handles Its Own Failures

Most component libraries stop at "here's a form" and "here's a table." This batch covers the states those two things spend most of their real life in: a form the user is mid-edit on and might walk away from, a delete button that needs real friction before it fires, and a data table that has to render a loading state, an empty state, and a genuine failure state — not just the one where the API call happens to succeed. Every one still loads the genuine bootstrap.min.css and bootstrap.bundle.min.js from a CDN and builds on Bootstrap's real component classes.

Every one is a live, interactive preview you can try right here in the article, and each exports to React, Vue, Angular or Tailwind in one click from its snippet page.

What these ten get right

  • Timing that respects real typing. The autosave status indicator debounces every keystroke into a single save 1.2 seconds after the user actually pauses, and guards the save itself with an isSaving flag so a keystroke landing mid-save queues exactly one follow-up save instead of firing a second overlapping request.
  • Time as the confirmation, not a second dialog. The hold-to-confirm delete button times its CSS fill transition to match its setTimeout exactly, so the visual progress and the actual deletion complete at the same instant — releasing early cancels with a fast reset instead of reusing the slow fill-in duration.
  • Browser-level protection, not just a click handler. The unsaved-changes alert pairs an interceptable in-app navigation click with a genuine window.beforeunload listener, since a modal can only ever catch one of those two ways a user actually tries to leave a page.
  • Every table state gets its own honest render. The loading skeleton's bars are shaped per column instead of uniform rectangles, and the error state replaces only the table body — never the column headers — so a failed fetch never costs the user their sense of what the table was supposed to show.
  • A guaranteed-reachable failure path. The data table error state and the bulk toolbar's delete both make sure their less-common outcome — a failed request, a destructive confirmation — is something you can actually click through in this preview, not something buried behind a lucky random roll.

1. Bootstrap Unsaved Changes Alert

A profile form that tracks its own dirty state and warns with a real modal — Keep editing, Discard & leave, or Save & leave — before an in-app navigation, plus a genuine beforeunload guard for a real page exit.

How it works: a single isDirty flag is flipped by an input listener on every field, and clicking "Back to dashboard" while it's true opens a modal instead of leaving immediately. "Discard & leave" restores the fields to their last saved snapshot rather than just closing the dialog, and "Save & leave" runs the exact same save() function the visible Save button uses. A separate window.beforeunload listener, gated behind the same isDirty check, is the real protection against a tab close or address-bar navigation — a click handler alone could never catch that.

Best for: settings and profile pages, and any multi-field form where an accidental navigation shouldn't silently discard real work. Tip: the beforeunload dialog won't visibly fire inside a sandboxed preview iframe, but the listener itself is the exact line a real page needs.

Grab the code: Bootstrap Unsaved Changes Alert

2. Bootstrap Form Autosave Status

A note editor that autosaves 1.2 seconds after you stop typing — Saving, Saved with a real timestamp, or Failed with a working Retry — instead of a plain "Save" button.

How it works: every keystroke clears a previous setTimeout and restarts a 1200ms one, so performSave() only actually runs once typing genuinely pauses. An isSaving flag guards against two overlapping requests — a keystroke landing mid-save sets a pendingResave flag instead of firing a second request, and exactly one more save runs the instant the current one resolves. A simulated 15% failure rate keeps the Failed state and its Retry link — which calls the identical performSave() function — genuinely reachable in this preview.

Best for: notes, long-form docs, and any editor where an explicit Save button interrupts the writing flow. Tip: the same debounce-plus-in-flight-guard pattern applies directly to a search-as-you-type input hitting a real API.

Grab the code: Bootstrap Form Autosave Status

3. Bootstrap Two-Factor Backup Codes Display

Ten single-use backup codes in a grid — click one to mark it redeemed, copy or download the full set, and regenerate through a confirmation modal that invalidates the old codes.

How it works: each code is an object carrying its own used boolean, so clicking an already-used code is a real no-op rather than a style with nothing behind it. Codes are generated from a character set that deliberately excludes 0/O and 1/I, since backup codes are the kind of thing someone reads off a screen and types by hand. Regenerating is destructive — it invalidates every code, used or not — so it's gated behind a real Bootstrap modal instead of firing on one click.

Best for: two-factor authentication setup flows and account security settings pages. Tip: the download button triggers a real file via Blob/URL.createObjectURL, which can be silently blocked inside a sandboxed preview iframe without allow-downloads — it works normally on a real page.

Grab the code: Bootstrap Two-Factor Backup Codes Display

4. Bootstrap Password Requirements Checklist

Five password rules that tick off individually as you type, with a submit button that only enables once every single one passes.

How it works: a RULES object maps each requirement's name to a small test function, and every <li> carries a data-rule attribute matching one of those keys — the update loop never hardcodes which item is which, it just reads the rule name straight off the element. Every rule re-evaluates from scratch on each keystroke, and the submit button's disabled state is derived from the same passing-rule count driving the visible checklist, so the two can never disagree.

Best for: signup forms and password-reset flows, especially paired with a strength meter for a combined percentage-plus-checklist view. Tip: adding a sixth requirement is a one-line addition to RULES plus one new list item — nothing else needs to change.

Grab the code: Bootstrap Password Requirements Checklist

5. Bootstrap Hold-to-Confirm Delete Button

Press and hold for 1.5 seconds to delete — a visible fill sweeps across the button in real time, and releasing early cancels instantly instead of completing the action.

How it works: a single HOLD_MS constant drives both the CSS transition duration on the fill element and a matching setTimeout, so the visual progress and the actual delete complete at the exact same instant. Releasing early swaps in a much shorter 180ms transition before resetting the fill to zero — reusing the slow fill-in duration for the reset would make cancelling feel as slow as completing. Keyboard users get the identical behavior via Space/Enter, guarded against the OS's own key-repeat re-firing the hold on every repeated keydown.

Best for: destructive actions in settings or admin panels where a full confirmation modal feels heavier than the action warrants — especially on touch devices, where a long, deliberate hold is far less likely to be accidental than a tap. Tip: change the single HOLD_MS constant to retune the duration; both the timer and the animation read from it, so they can never drift apart.

Grab the code: Bootstrap Hold-to-Confirm Delete Button

6. Bootstrap Bulk Action Toolbar

Select one or more table rows and the header swaps for a bulk-action toolbar — Archive, Delete behind a real confirmation modal, and Clear — disappearing the instant nothing is selected.

How it works: a single refresh() function reads how many row checkboxes are checked and toggles the toolbar and default header from that one number, so they can never both show (or both hide) at once. The header checkbox's three real states — checked, unchecked, or a genuine indeterminate — are recomputed the same way every time, derived from the same count. Archive applies instantly as a soft, reversible action; Delete actually removes rows, so it's gated behind a confirmation modal whose message is generated from the live selection count.

Best for: admin dashboards managing users, orders, or content where selecting several rows should surface a set of relevant actions. Tip: the DOM indeterminate property has to be set in JavaScript — it has no effect as a plain HTML attribute, a common mistake when building this pattern from scratch.

Grab the code: Bootstrap Bulk Action Toolbar

7. Bootstrap Sticky Table Header on Scroll

A 24-row table inside a fixed-height scroll box whose header stays pinned via genuine position: sticky, with a JavaScript-driven shadow that only appears once real content has scrolled underneath it.

How it works: position: sticky on the header cells is scoped to their own scrolling container (a fixed max-height plus overflow-y: auto), not the page — without that scoped scroll context, the header has nothing to stick within. The header needs an explicit opaque background too, or rows scrolling underneath would show through it. The one line of JavaScript toggles a shadow class based on scrollTop > 0, so the header only looks "elevated" once there's actually something scrolled beneath it.

Best for: any table with more rows than fit on screen at once — dashboards, order history, activity logs. Tip: the same position: sticky mechanism extends to a frozen first column with left: 0 instead of top: 0.

Grab the code: Bootstrap Sticky Table Header on Scroll

8. Bootstrap No Search Results State

A filtered list whose empty state echoes back the user's exact search text — "No results for 'xyz'" — with a one-click Clear search that immediately restores the full list and refocuses the input.

How it works: one render() function is the single source of truth for whether the list or the empty state shows, filtering by a case-insensitive substring match and echoing the literal, unmodified query back into the message. An empty search box is deliberately treated as "no filter applied," correctly returning every item rather than zero — the difference between a search that found nothing and a search that hasn't started yet.

Best for: any filterable list, dropdown, or product search where a vague "nothing found" leaves a user wondering if their search even registered. Tip: distinguish this from a true first-time empty state — this one means the data exists but the current search didn't find it.

Grab the code: Bootstrap No Search Results State

9. Bootstrap Data Table Loading Skeleton

Shimmering skeleton rows shaped like the real table's columns while data "loads," swapped for actual rows once it resolves — with a Reload button to trigger the cycle again on demand.

How it works: each skeleton bar's width is set per column — narrower for a name, wider for an email — so the loading state resembles this specific table rather than reading as a generic placeholder. The shimmer itself is a pure CSS animation sweeping an oversized background gradient's position, with zero JavaScript driving the visual effect frame by frame. The Reload button disables itself for the duration of the simulated fetch so a second click can't start an overlapping load.

Best for: any table that loads asynchronously after the initial page render, avoiding a jarring jump between "nothing" and "a full table." Tip: pair with the error state below for the complete set of outcomes a real fetch actually has.

Grab the code: Bootstrap Data Table Loading Skeleton

10. Bootstrap Data Table Error State

A table whose very first load is scripted to fail — a centered inline message with a working Retry button replaces the rows, while the column headers never move.

How it works: only the <tbody> is ever replaced between loading, error, and loaded states — the column headers stay put the whole time, so a user never loses context for what the table is supposed to show. The error message is a real table row with colspan, not an absolutely positioned overlay that would need its own sizing logic. The first attempt is deliberately scripted to fail so the error state is guaranteed to be visible in this preview; every retry after that has a genuine 60% chance of succeeding, and Retry always calls the exact same load() function a fresh page load uses.

Best for: any dashboard table backed by a real, occasionally-unreliable API — billing, order history, anything where a silently empty table on failure would be actively misleading. Tip: remove the guaranteed-first-failure special case in production and let the real fetch outcome decide every time.

Grab the code: Bootstrap Data Table Error State

Same as every batch before it, each of these ten lives in the category that actually fits its shape, so they surface alongside every other snippet of that kind rather than sitting in a library of their own. Find these ten and every other Bootstrap snippet in the collection in one place via the Bootstrap tag. Open any of them above and you land straight in the live editor, HTML/CSS/JS tabs and all; click Save as to copy it into My Code and start changing it.

About the author

Puneet Sharma
Puneet Sharma is a freelance web developer and the creator of FWD Tools and WebDevPuneet. Follow him on X/Twitter

Post a Comment