Skip to content
  • No data uploaded
  • Instant results

Bootstrap 5 Login Modal for Vanilla JS — Glassmorphism

A production-ready glassmorphism login modal: a centered sign-in dialog with email and password fields, “remember me”, a forgot-password link and a social sign-in button. Pick your brand color, toggle dark mode and corner radius — the live preview and the Vanilla JS code update instantly in your browser.

Live component editor

Library
Framework
Style
Theme
Corner radius
Live preview
<!-- Requires Bootstrap 5.3 CSS + theme.css:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="theme.css"> -->
<div>
  <button type="button" class="btn btn-brand fw-semibold rounded-2" data-open="open">Sign in</button>
  <div data-show="open">
    <div class="position-fixed top-0 start-0 w-100 h-100 z-3 d-flex align-items-center justify-content-center p-3 overlay" role="dialog" aria-modal="true" aria-labelledby="login-title">
      <div class="position-relative w-100 mw-md p-5 glass shadow-lg rounded-3">
        <button type="button" class="position-absolute top-0 end-0 m-2 btn btn-sm btn-link link-secondary text-decoration-none" aria-label="Close" data-close="open">&times;</button>
        <h2 id="login-title" class="fs-4 fw-bold mb-1 text-body-emphasis">Welcome back</h2>
        <p class="small mb-4 text-body-secondary">Sign in to continue to your dashboard.</p>
        <form class="d-flex flex-column gap-3">
          <div>
            <label for="login-email" class="form-label small fw-medium">Email</label>
            <input id="login-email" type="email" autocomplete="email" placeholder="you@company.com" class="form-control rounded-2" required>
          </div>
          <div>
            <div class="d-flex align-items-center justify-content-between">
              <label for="login-password" class="form-label small fw-medium">Password</label>
              <a href="#" class="small text-brand fw-medium text-decoration-none">Forgot?</a>
            </div>
            <input id="login-password" type="password" autocomplete="current-password" placeholder="••••••••" class="form-control rounded-2" required>
          </div>
          <label class="d-flex align-items-center gap-2 small text-body">
            <input type="checkbox" class="form-check-input mt-0"> Remember me for 30 days
          </label>
          <button type="submit" class="btn btn-brand fw-semibold rounded-2 w-100">Sign in</button>
        </form>
        <div class="d-flex align-items-center gap-2 my-4">
          <span class="flex-fill border-top"></span>
          <span class="small text-uppercase text-body-secondary">or</span>
          <span class="flex-fill border-top"></span>
        </div>
        <button type="button" class="btn btn-outline-secondary fw-semibold rounded-2 w-100">Continue with Google</button>
        <p class="mt-4 text-center small text-body-secondary">No account? <a href="#" class="text-brand fw-medium text-decoration-none">Create one</a></p>
      </div>
    </div>
  </div>
</div>

<script>
  (() => {
    const state = { open: true };
    const actions = {  };
    const pair = (s) => s.split(':');
    const sync = () => {
      document.querySelectorAll('[data-show]').forEach((el) => (el.hidden = !state[el.dataset.show]));
      document.querySelectorAll('[data-hide]').forEach((el) => (el.hidden = !!state[el.dataset.hide]));
      document.querySelectorAll('[data-when]').forEach((el) => { const [k, v] = pair(el.dataset.when); el.hidden = state[k] !== v; });
      document.querySelectorAll('[data-pressed]').forEach((el) => { const [k, v] = pair(el.dataset.pressed); el.setAttribute('aria-pressed', String(state[k] === v)); });
      document.querySelectorAll('[data-expanded]').forEach((el) => el.setAttribute('aria-expanded', String(!!state[el.dataset.expanded])));
    };
    document.addEventListener('click', (e) => {
      const t = e.target.closest('[data-toggle],[data-open],[data-close],[data-set],[data-call]');
      if (!t) return;
      const { toggle, open, close, set, call } = t.dataset;
      if (call) actions[call]?.(e);
      if (toggle) state[toggle] = !state[toggle];
      if (open) state[open] = true;
      if (close) state[close] = false;
      if (set) { const [k, v] = pair(set); state[k] = v; }
      sync();
    });
    sync();
  })();
</script>
All components →

Free Bootstrap 5 Login Modal for Vanilla JS — Glassmorphism by pGento

Install Bootstrap 5 for Vanilla JS

Include Bootstrap 5.3 from the CDN (or npm install bootstrap) and the generated theme.css:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="theme.css">

Use the login modal in Vanilla JS

Paste the markup where the component should appear. The small inline <script> wires up the interactive state with one delegated click listener — no framework needed.

Accessibility & customization

The dialog uses role="dialog", aria-modal="true" and aria-labelledby pointing at its title. Every field has a visible <label>, the close button has an aria-label, and inputs use the correct autocomplete tokens so password managers work.

Every color, radius and dark-mode choice is baked into plain Bootstrap classes plus a tiny CSS-variable theme file, so the copied code has no runtime dependency on this site. The glass style relies on backdrop-filter, supported in all current browsers; place it over a colorful background for the best effect.

Compatibility

ItemDetails
CSS frameworkBootstrap 5.3+ (CSS only)
LibraryPlain HTML + optional vanilla JS
Interactive stateopen
Dark modeYes — toggle in the editor
StyleGlassmorphism (backdrop blur)

Frequently asked questions

How do I install this Bootstrap login modal in Vanilla JS?
Create a web page, install Bootstrap 5 as shown in the installation section, then paste the generated code. Also save the generated theme.css file.
Can I change the color of the login modal?
Yes. Use the brand color picker or type any hex code — the preview and code update instantly, and the color is written directly into the classes you copy.
Does the login modal support dark mode?
Yes. Toggle “Dark mode” in the editor to generate a dark palette version of the same component.
Is the login modal accessible?
The dialog uses role="dialog", aria-modal="true" and aria-labelledby pointing at its title. Every field has a visible <label>, the close button has an aria-label, and inputs use the correct autocomplete tokens so password managers work.
Is this component free for commercial use?
Yes. The generated code is yours to use in personal and commercial projects without attribution.
Bootstrap 5 Login Modal for Vanilla JS — Glassmorphism

Embed this tool on your site

Paste this code into any web page. It stays free, fast and ad-free inside your site.

Print or save as PDF

Prints just this tool and its result. Choose “Save as PDF” as the printer to get a file. Branding is stored only in this browser.