Snippets Card

Bootstrap 5 Survey Form with Modal and Side Panel

A short feedback survey with a five-step rating scale and optional comment, shown inline and also as a modal and a side panel.

Bootstrap 5 No jQuery Oct 2019 4.3K views

<section class="wdw-stage">
  <div class="container" style="max-width: 980px;">
    <div class="wdw-card overflow-hidden">
      <div class="row g-0">
        <div class="col-lg-5 wdw-aurora p-4 p-md-5 d-flex flex-column justify-content-between gap-5">
          <div>
            <span class="wdw-eyebrow sv-eyebrow">Quick survey</span>
            <h2 class="wdw-heading sv-title display-6 mt-2 mb-3">Your opinion matters</h2>
            <p class="mb-0 sv-lead">Have some ideas on how to improve our product? Give us your feedback — it takes less than a minute.</p>
          </div>
          <div class="d-grid gap-2">
            <button type="button" class="btn btn-light rounded-pill px-4" data-bs-toggle="modal" data-bs-target="#svModal">Open as modal</button>
            <button type="button" class="btn btn-outline-light rounded-pill px-4" data-bs-toggle="offcanvas" data-bs-target="#svPanel" aria-controls="svPanel">Open as side panel</button>
          </div>
        </div>
        <div class="col-lg-7 p-4 p-md-5 d-flex align-items-center"><div class="w-100">
          <form class="sv-form" data-survey novalidate>
  <fieldset class="mb-3">
    <legend class="fs-6 fw-semibold mb-2">How would you rate the product?</legend>
    <div class="sv-scale"><input type="radio" class="btn-check" name="sv1Rating" id="sv1R1" value="1" required><label class="sv-tile" for="sv1R1"><span class="sv-num">1</span><span class="sv-lbl">Very bad</span></label><input type="radio" class="btn-check" name="sv1Rating" id="sv1R2" value="2" required><label class="sv-tile" for="sv1R2"><span class="sv-num">2</span><span class="sv-lbl">Bad</span></label><input type="radio" class="btn-check" name="sv1Rating" id="sv1R3" value="3" required><label class="sv-tile" for="sv1R3"><span class="sv-num">3</span><span class="sv-lbl">Mediocre</span></label><input type="radio" class="btn-check" name="sv1Rating" id="sv1R4" value="4" required><label class="sv-tile" for="sv1R4"><span class="sv-num">4</span><span class="sv-lbl">Good</span></label><input type="radio" class="btn-check" name="sv1Rating" id="sv1R5" value="5" required><label class="sv-tile" for="sv1R5"><span class="sv-num">5</span><span class="sv-lbl">Very good</span></label></div>
    <div class="sv-caption small fw-semibold text-primary mt-2" aria-live="polite"></div>
    <div class="text-danger small fw-medium sv-err" role="alert" hidden>Please choose a rating.</div>
  </fieldset>
  <div class="mb-4">
    <label for="sv1Note" class="form-label fw-semibold">Any ideas to improve it? <span class="fw-normal wdw-muted">(optional)</span></label>
    <textarea class="form-control sv-note" id="sv1Note" rows="3" placeholder="Tell us what would make it better"></textarea>
  </div>
  <div class="d-flex gap-2 justify-content-end">
    <button type="button" class="btn btn-outline-secondary rounded-pill px-4" data-sv-reset>Clear</button>
    <button type="submit" class="btn btn-primary rounded-pill px-4">Send feedback</button>
  </div>
  <div class="sv-thanks text-center py-4" hidden>
    <div class="wdw-icon mb-3"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg></div>
    <h3 class="h5 wdw-heading mb-1">Thank you!</h3>
    <p class="wdw-muted mb-3">Your feedback helps us improve.</p>
    <button type="button" class="btn btn-outline-primary btn-sm rounded-pill px-3" data-sv-reset>Send another</button>
  </div>
</form></div>
        </div>
      </div>
    </div>
  </div>

  <div class="modal fade" id="svModal" tabindex="-1" aria-labelledby="svModalTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
      <div class="modal-content border-0 rounded-4 shadow">
        <div class="modal-header border-0 pb-0"><h2 class="modal-title h5 wdw-heading" id="svModalTitle">Quick survey</h2><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button></div>
        <div class="modal-body p-4"><form class="sv-form" data-survey novalidate>
  <fieldset class="mb-3">
    <legend class="fs-6 fw-semibold mb-2">How would you rate the product?</legend>
    <div class="sv-scale"><input type="radio" class="btn-check" name="sv2Rating" id="sv2R1" value="1" required><label class="sv-tile" for="sv2R1"><span class="sv-num">1</span><span class="sv-lbl">Very bad</span></label><input type="radio" class="btn-check" name="sv2Rating" id="sv2R2" value="2" required><label class="sv-tile" for="sv2R2"><span class="sv-num">2</span><span class="sv-lbl">Bad</span></label><input type="radio" class="btn-check" name="sv2Rating" id="sv2R3" value="3" required><label class="sv-tile" for="sv2R3"><span class="sv-num">3</span><span class="sv-lbl">Mediocre</span></label><input type="radio" class="btn-check" name="sv2Rating" id="sv2R4" value="4" required><label class="sv-tile" for="sv2R4"><span class="sv-num">4</span><span class="sv-lbl">Good</span></label><input type="radio" class="btn-check" name="sv2Rating" id="sv2R5" value="5" required><label class="sv-tile" for="sv2R5"><span class="sv-num">5</span><span class="sv-lbl">Very good</span></label></div>
    <div class="sv-caption small fw-semibold text-primary mt-2" aria-live="polite"></div>
    <div class="text-danger small fw-medium sv-err" role="alert" hidden>Please choose a rating.</div>
  </fieldset>
  <div class="mb-4">
    <label for="sv2Note" class="form-label fw-semibold">Any ideas to improve it? <span class="fw-normal wdw-muted">(optional)</span></label>
    <textarea class="form-control sv-note" id="sv2Note" rows="3" placeholder="Tell us what would make it better"></textarea>
  </div>
  <div class="d-flex gap-2 justify-content-end">
    <button type="button" class="btn btn-outline-secondary rounded-pill px-4" data-bs-dismiss="modal">Cancel</button>
    <button type="submit" class="btn btn-primary rounded-pill px-4">Send feedback</button>
  </div>
  <div class="sv-thanks text-center py-4" hidden>
    <div class="wdw-icon mb-3"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg></div>
    <h3 class="h5 wdw-heading mb-1">Thank you!</h3>
    <p class="wdw-muted mb-3">Your feedback helps us improve.</p>
    <button type="button" class="btn btn-outline-primary btn-sm rounded-pill px-3" data-sv-reset>Send another</button>
  </div>
</form></div>
      </div>
    </div>
  </div>

  <div class="offcanvas offcanvas-end" tabindex="-1" id="svPanel" aria-labelledby="svPanelTitle">
    <div class="offcanvas-header"><h2 class="offcanvas-title h5 wdw-heading" id="svPanelTitle">Quick survey</h2><button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button></div>
    <div class="offcanvas-body"><form class="sv-form" data-survey novalidate>
  <fieldset class="mb-3">
    <legend class="fs-6 fw-semibold mb-2">How would you rate the product?</legend>
    <div class="sv-scale"><input type="radio" class="btn-check" name="sv3Rating" id="sv3R1" value="1" required><label class="sv-tile" for="sv3R1"><span class="sv-num">1</span><span class="sv-lbl">Very bad</span></label><input type="radio" class="btn-check" name="sv3Rating" id="sv3R2" value="2" required><label class="sv-tile" for="sv3R2"><span class="sv-num">2</span><span class="sv-lbl">Bad</span></label><input type="radio" class="btn-check" name="sv3Rating" id="sv3R3" value="3" required><label class="sv-tile" for="sv3R3"><span class="sv-num">3</span><span class="sv-lbl">Mediocre</span></label><input type="radio" class="btn-check" name="sv3Rating" id="sv3R4" value="4" required><label class="sv-tile" for="sv3R4"><span class="sv-num">4</span><span class="sv-lbl">Good</span></label><input type="radio" class="btn-check" name="sv3Rating" id="sv3R5" value="5" required><label class="sv-tile" for="sv3R5"><span class="sv-num">5</span><span class="sv-lbl">Very good</span></label></div>
    <div class="sv-caption small fw-semibold text-primary mt-2" aria-live="polite"></div>
    <div class="text-danger small fw-medium sv-err" role="alert" hidden>Please choose a rating.</div>
  </fieldset>
  <div class="mb-4">
    <label for="sv3Note" class="form-label fw-semibold">Any ideas to improve it? <span class="fw-normal wdw-muted">(optional)</span></label>
    <textarea class="form-control sv-note" id="sv3Note" rows="3" placeholder="Tell us what would make it better"></textarea>
  </div>
  <div class="d-flex gap-2 justify-content-end">
    <button type="button" class="btn btn-outline-secondary rounded-pill px-4" data-bs-dismiss="offcanvas">Cancel</button>
    <button type="submit" class="btn btn-primary rounded-pill px-4">Send feedback</button>
  </div>
  <div class="sv-thanks text-center py-4" hidden>
    <div class="wdw-icon mb-3"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg></div>
    <h3 class="h5 wdw-heading mb-1">Thank you!</h3>
    <p class="wdw-muted mb-3">Your feedback helps us improve.</p>
    <button type="button" class="btn btn-outline-primary btn-sm rounded-pill px-3" data-sv-reset>Send another</button>
  </div>
</form></div>
  </div>
</section>

Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.

Free to use in personal and commercial projects under the MIT license.