Skip to the page content

Form wizards

Multi-step forms as a stepper, tabs, a side rail, one question at a time or a dialog.

8 wizards

Numbered stepper with side summary

Numbered steps across the top, done in order. Use it for a fixed, linear flow. Each step is checked before you move on, a side panel updates from the fields as you type, and the review step has Change buttons that jump back to any step. The sample is a four-step checkout.

Stepper

    Your bag

    • ML-BLAZ · Deep violet, size M · $1,290.00

      $1,290.00

    • ML-LOAF · Deep violet, US 8 · $790.00

      $1,580.00

    • ML-OXFD · Black and ivory, US 9 · $850.00

      $850.00

    An Insider member? INSIDERS takes 10% off.

    Show code
    <div data-wiz="checkout" class="wiz">
      <ol data-wiz-steps class="wiz-steps"></ol>   <!-- one entry per panel, drawn by the script -->
      <form data-wiz-form novalidate>
        <div data-wiz-errors tabindex="-1" class="wiz-summary" hidden></div>
        <section data-wiz-panel="bag" data-wiz-label="Bag" class="wiz-panel">…</section>
        <section data-wiz-panel="delivery" data-wiz-label="Delivery" class="wiz-panel" hidden>
          <input data-wiz-msg="Enter an email address" id="co-email"
                 aria-describedby="co-email-error" type="email" required>
          <p id="co-email-error" class="wiz-error" hidden></p>
        </section>
        <button data-wiz-back type="button" hidden>Back</button>
        <button data-wiz-next data-wiz-finish="Place order" type="submit">Continue</button>
      </form>
    </div>
    
    stepFlow(host, {
      verify: { bag: () => (unitsInBag() ? [] : [{ field: quantities[0], text: 'Add at least one item to check out' }]) },
      submit: (finish) => sendOrder().then(finish),
    });

    Compact progress bar

    A segmented bar with a step count and label, for settings panels with little room. It supports checks across fields, like To not being below From, and resets after saving so the next entry starts clean.

    Progress bar
    • Lower 48$4.95 · free over $40 · 2 to 3 days
    • Alaska and Hawaii$12.00 · 4 to 7 days

    Step 1 of 4Where

    Where

    Up to twelve.

    Show code
    <p><span data-sz-count>Step 1 of 4</span> <span data-sz-label>Where</span></p>
    <div class="wiz-segments wiz-segments-bar"><span></span>…</div>
    
    const flow = stepFlow(host, {
      verify: { time: () => (slowest() < quickest() ? [{ field: slowestInput, text: 'The longest time can't be shorter than the quickest' }] : []) },
      submit: (finish) => { finish(); addSavedZone(zoneName); flow.startOver(); },
    });

    Progress ring

    A small ring with the current and next step name in place of a step list. Use it where a row of steps won't fit. The last step can preview the answers, as the seat invite does here.

    Progress ring

    Recipient

    Next: Plan

    Who is the seat for?

    Show code
    <div class="basalt-ring basalt-ring-sm value-25" role="img" aria-label="Step 1 of 4">…</div>
    
    stepFlow(host, {
      stepChanged: ({ offset, count }) => {
        ring.style.setProperty('--value', Math.round(((offset + 1) / count) * 100));
        ring.setAttribute('aria-label', `Step ${offset + 1} of ${count}`);
      },
    });

    Tabbed sections with completeness meter

    Sections as tabs, filled in any order. Use it for editing a record where the order doesn't matter. Each tab checks itself off when its fields pass, a segmented meter counts them, arrow keys move between tabs, and submitting lists whatever is still missing.

    Tabs

    2 of 4 sections ready

    Draft
    Category

    Saved as a draft

    Show code
    <div role="tablist">
      <button role="tab" aria-controls="pr-pricing" aria-selected="false" tabindex="-1">
        <i class="bi bi-circle" data-pr-icon></i>Pricing
      </button>
    </div>
    <div role="tabpanel" id="pr-pricing" data-pr-section="Pricing" hidden>…</div>
    
    /* A tab turns ready once its panel passes; arrow keys, Home and End walk the tabs. */
    find('[data-pr-icon]', tab).className = `bi ${ready ? 'bi-check-circle-fill' : 'bi-circle'}`;

    Wizard in a dialog

    A short wizard inside a modal, opened from the record it belongs to. Use it for quick tasks that shouldn't leave the page. Escape closes it, each open starts fresh, and the result is written back to the record.

    Dialog

    Order #20391

    Delivered September 12 · $5,090.00

    Delivered
    • Shield Sunglasses2 × ML-SHLD · $1,040.00
    • Leather Trench Coat1 × ML-TRCH · $3,200.00
    • Two-Tone Oxfords1 × ML-OXFD · $850.00

    Returns are open until September 26.

    Show code
    <div class="modal fade" id="rt-modal" tabindex="-1" aria-labelledby="rt-modal-title">
      <form class="modal-content" data-wiz-form novalidate>
        <div class="basalt-dialog-head">…</div>
        <div class="basalt-dialog-body"><div data-wiz-panel="items">…</div></div>
        <div class="basalt-dialog-foot"><button type="submit" data-wiz-next>Continue</button></div>
      </form>
    </div>
    
    /* Every opening starts the flow from a clean slate. */
    dialog.addEventListener('show.bs.modal', () => flow.startOver());

    Vertical rail with saved draft

    Sections listed down the side, each with its own status: not started, in progress, needs attention or done. Use it for long forms people fill in over more than one sitting. Sections open in any order, the final button checks them all, and a draft is kept in this browser.

    Vertical rail

      About your business

      Leave it blank if you don't have one yet.

      Show code
      <ol class="wiz-steps wiz-steps-rail" data-wiz-steps></ol>
      
      stepFlow(host, {
        anyOrder: true,   /* sections open in any order; the last button checks every one */
        describe: (section, problems, attempted, visited) => statusLine(problems, attempted, visited),
      });
      
      /* The draft sits in localStorage, inside try because a browser may refuse it. */
      try { localStorage.setItem('basalt-wizard-fleet', JSON.stringify(captureDraft())); } catch (error) {}

      One question per screen

      A single question with large lettered answers on each screen. Use it for short quizzes and sign-up questions, like this plan finder. A letter key picks an answer, Enter moves on, and the last step shows a result.

      One question

      Question 1 of 3

      How many staff do you send out?

      Press A to D, then Enter

      Show code
      <fieldset class="wiz-answers">
        <legend class="wiz-quiz-q">Do customers book visits online?</legend>
        <label class="wiz-answer">
          <input type="radio" name="qz-booking" value="most" required>
          <span aria-hidden="true" class="wiz-answer-key">A</span>Most visits
        </label>
      </fieldset>
      
      /* A to D choose an answer, except while someone is typing in a text field. */
      host.addEventListener('keydown', (event) => {
        const letter = 'abcd'.indexOf(event.key.toLowerCase());
        if (letter < 0 || event.target.matches('input[type=text], textarea')) return;
        answers()[letter]?.click();
      });

      Branching steps

      Steps that appear or drop out depending on an earlier answer, with the pill list rebuilt each time. Use it when some questions only apply to some people. Here, Garden adds a garden step, Windows a windows step, and Both adds the two. The sample builds a maintenance plan for a customer.

      Branching

        What does the plan cover?

        System

        $178.00 a visit

        Show code
        <section data-wiz-panel="cooling" data-wiz-label="Windows" data-wiz-when="cooling" hidden>…</section>
        
        const flow = stepFlow(host, {
          /* A panel marked data-wiz-when stays in the flow only while this returns true. */
          include: (key) => coverage() === key || coverage() === 'both',
        });
        for (const option of coverageOptions) option.addEventListener('change', () => flow.syncBranches());