webdevpuneet.com

Bootstrap Version History Panel — Free HTML CSS JS Snippet

Bootstrap Version History Panel · Dashboards · Plain HTML, CSS & JS · Live preview

CategoryDashboards

Copy & paste

Source Code

<div class="container py-5 d-flex justify-content-center">
  <div class="card bsver-card">
    <div class="card-body p-3">
      <h6 class="fw-bold mb-2">Version history</h6>
      <ul class="list-unstyled mb-0" id="bsverList"></ul>
    </div>
  </div>
</div>

<div class="modal fade" id="bsverModal" tabindex="-1" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title fw-bold">Restore this version?</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
      </div>
      <div class="modal-body">
        <p class="mb-0" id="bsverModalBody"></p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Cancel</button>
        <button type="button" class="btn btn-dark fw-bold" id="bsverConfirm">Restore</button>
      </div>
    </div>
  </div>
</div>

Extend with AI

Take This Snippet Further With AI

The AI prompt for this one is for Patreon supporters ($3 a month, 7 days free), along with a site with no ads. Supporters enter the passcode once and it is remembered in this browser.

· Become a supporter

What's included

Features

"Current" is a single comparison, not a flag stored on any individual version, so it can move freely between rows
The current version never shows its own Restore button, since restoring onto itself would be meaningless
Restoring requires a real confirmation naming the specific version's author and summary, not a generic warning
Cancelling the confirmation leaves the current version completely unchanged
Any version, including a previously-current one, can be restored back to at any time

About this UI Snippet

Bootstrap Version History Panel — HTML, CSS & JavaScript

Screenshot of the Bootstrap Version History Panel snippet rendered live

The "current" state isn't a property baked into any one version — it's a single currentId variable compared against every version's id at render time, which is what makes restoring an older version as simple as reassigning currentId and re-rendering, with the "current" badge and the missing Restore button both automatically following that reassignment on whichever row now matches.

The current version deliberately has no Restore button of its own — isCurrent ? '' : '...button...' withholds it, since restoring the version you're already on is a meaningless action a real interface shouldn't offer at all, rather than offering it and having it silently do nothing.

Restoring is a genuine two-step confirmation: clicking "Restore" on a row stores pendingRestoreId and opens a modal whose message is generated from that specific version's real summary and author, not a generic "are you sure?" — only clicking "Restore" inside the modal actually reassigns currentId. That separation matters because restoring an old version is inherently destructive to whatever's currently live, the same reasoning behind gating deletion behind a confirmation elsewhere in this collection.

Step by step

How to Use

  1. 1
    Load the snippetVersion 5 is marked "(current)" in green with no Restore button; every older version has one.
  2. 2
    Click "Restore" on version 3A modal opens naming exactly what v3 contains and who authored it, asking for confirmation.
  3. 3
    Click "Restore" inside the modalVersion 3 becomes marked "(current)", and it now has no Restore button — the same logic that applied to v5 originally.
  4. 4
    Click "Restore" on version 5 (the one that used to be current)It works the same way — restoring is fully reversible in the sense that any version can become current again.
  5. 5
    Open the restore confirmation and click "Cancel" insteadNothing changes — the current version stays exactly as it was.

Real-world uses

Common Use Cases

DEV
CMS and document editors with version tracking
Pairs with bootstrap-diff-viewer to show exactly what changed between the current content and a version before restoring it.
Configuration and settings history in admin tools
Let an operator roll back a configuration change with a clear, specific confirmation of what they're restoring.
Design tools and collaborative editors
A standard "restore this version" pattern for any collaboratively edited document or file.

Got questions?

Frequently Asked Questions

Yes — currentId is just a plain comparison value, not a one-way flag, so any version (including the one that was current before the last restore) can be restored to at any time.

Nothing — currentId is only ever reassigned inside the modal's own Restore button handler, so dismissing or cancelling the modal leaves the current version completely untouched.

Restoring the version that's already current is a no-op that shouldn't be presented as an available action — omitting the button entirely is clearer than showing one that would do nothing.

Yes. Keep the versions array and currentId in component state, derive each row's "current" and Restore-button-visibility from a comparison in the render function, and manage the confirmation modal's open state and pending version id the same way.