Skip to content

Multi-Step Modal Dialog

Tailwind CSS modal with a three-step wizard: template picker, validated details form and review, plus stepper, focus trap and Escape to close.

Also known as: wizard modal, multi step popup, step by step dialog, create project modal, modal with stepper

Tailwind CSS Modals Responsive #dialog #form #modal #stepper #wizard

Multi-Step Modal Dialog live demo

Open in new tab

Tailwind CSS code (HTML, CSS, JS)

A multi-step modal dialog built with Tailwind CSS and vanilla JavaScript that walks users through a short "Create a project" wizard: pick a template, enter validated details, then review and confirm. Use it for onboarding, checkout steps, setup flows or any task that is too long for one screen but too short for its own page.

How it works

The root is .msm-wizard. It holds an empty-state card with the trigger button (data-msm-open), a role="status" message (data-msm-result) and the .msm-overlay, which starts hidden. Inside the overlay is the #msm-dialog panel with a header, a progress stepper (ol with three data-msm-indicator items), a scrollable form with three fieldset elements marked data-msm-step, and a footer with Back (data-msm-back) and the primary button (data-msm-next).

On DOMContentLoaded the script initializes every .msm-wizard. Opening the dialog resets the form, shows step one, locks page scrolling and moves focus into the step. The primary button is a submit button, so both a click and Enter in a field fire the form's submit event; the handler calls preventDefault(), validates the current step and either moves forward or finishes. showStep() toggles hidden on the fieldsets, writes data-state="done|current|todo" and aria-current="step" on the stepper, updates the "Step 2 of 3" text and changes the button label to "Create project" on the last step, where fillReview() copies the answers into the data-msm-review cells. Finishing shows "Creating…" for 900 ms, closes the dialog and announces the result; replace that setTimeout with fetch() to save the project.

style.css colors the stepper bars, styles the selected template card with :has(input:checked) and adds the msm-rise and msm-slide animations.

Customization

  • Add a step by inserting another fieldset data-msm-step and a matching li data-msm-indicator, then change grid-cols-3 on the stepper ol.
  • validate() in script.js: add rules for new required fields; it currently checks data-msm-name.
  • data-msm-review cells: add one per field you want on the review step and a matching key in the map object in fillReview().
  • #7c3aed in style.css together with the violet-600 utilities: change the accent color.
  • max-w-lg on #msm-dialog: use max-w-2xl for wider forms.
  • items-end and sm:items-center on .msm-overlay: use items-center to center the panel on phones as well.
  • Delete the .msm-enter and .msm-enter-back rules in style.css to switch steps without sliding.

Use cases

  • Onboarding: guide new users through picking a template, entering details and confirming
  • Setup flows: a three-step dialog for tasks too long for one screen but too short for a page
  • Checkout steps: validation on each step before continuing, with a review before submit
  • Project tools: a Create project wizard with a stepper and Back and Next buttons
  • Accessible apps: the dialog traps focus, closes on Escape and returns focus to the trigger

Accessibility

The panel has role="dialog", aria-modal="true", aria-labelledby="msm-title" and is described by the live "Step x of 3" text, so each step change is announced. The trigger exposes aria-haspopup, aria-controls and aria-expanded. Focus is trapped inside the dialog, Escape closes it and focus returns to the trigger. Every step is a fieldset with a legend; the template cards are real radio buttons, and the name field uses aria-invalid plus aria-describedby for its error. All controls show a visible focus outline, and animations are switched off under prefers-reduced-motion.

Usage notes

The dialog stays below the viewport height and scrolls internally on small screens. For several wizards on one page, give each copy unique id values.

Multi-Step Modal Dialog at a glance

Framework
Tailwind CSS
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Tailwind CSS
Layout
Responsive, works on mobile
Category
Modals
License
Free for personal and commercial use

Questions about this template

Can I use the Multi-Step Modal Dialog code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Tailwind CSS from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>

The Tailwind browser build is for prototyping. In production, compile Tailwind with its CLI or your bundler.

Multi-Step Modal Dialog – Tailwind CSS modals component screenshot
Multi-Step Modal Dialog · Tailwind CSS Modals

More Modals

Multi-Step Wizard Dialog – Bootstrap 6 modals preview

Multi-Step Wizard Dialog

Bootstrap 6 Dialog wizard with three steps, a Stepper and progress bar, back/next buttons, per-step validation, Chips email invites and a review screen.

Image Lightbox Dialog – Bootstrap 6 modals preview

Image Lightbox Dialog

Dark Bootstrap 6 Dialog lightbox that opens gallery thumbnails large, with previous/next buttons, arrow-key and swipe navigation, captions and a photo counter.

Product Quick View Modal with Photo – Bootstrap 5 modals preview

Product Quick View Modal with Photo

Bootstrap 5 product quick view modal with photo, rating, material and size options that update price and image, quantity stepper and add to cart.

Newsletter Popup Dialog – Bootstrap 6 modals preview

Newsletter Popup Dialog

Bootstrap 6 Dialog newsletter popup with a photo side, email signup with validation, a don't-show-again option, delayed auto-open and a confirmation state.

Fullscreen Dialog on Mobile – Bootstrap 6 modals preview

Fullscreen Dialog on Mobile

Dark Bootstrap 6 Dialog for notification settings that is centered on desktop, fullscreen on phones, with a scrollable body of switches and a sticky footer.

Login Dialog with Social Buttons – Bootstrap 6 modals preview

Login Dialog with Social Buttons

Bootstrap 6 Dialog login form with Google, Apple and GitHub sign-in buttons, email and password fields, show-password toggle, validation and a success state.