Components/App/Questionnaire
COMPONENT56.56

Questionnaire

Multi-step form wizard over plain sibling forms. Each Continue validates natively; completion merges every step into one FormData event.


INSTALL

1pnpm dlx @sayagodev/mo add questionnaire

Or import the files from the package (no copy):

1import "@sayagodev/mo/css/questionnaire.css";2import "@sayagodev/mo/js/questionnaire.js";

EXAMPLES

Workspace setup

Account details

Tell us who will own this workspace.

Workspace invitations are sent from this address.
Validation gate

How much detail should the answer include?

Both fields are required — Continue stays on this step until they validate.

Inside a card

Create agent task

Two quick questions before the agent starts.

What should the agent work on?

Choose the task that should be handled next.

Choice cards

What should the agent build next?

Choose a direction or describe another task.

Multiple + skip

What should every progress update include?

Select all that apply, or skip this question.

Freeform input

What should the agent prototype next?

Choose a direction or write your own.

Three steps

Where should the agent run?

Cloud runs add an environment question to this flow.

USAGE

1<mo-questionnaire>2  <div data-questionnaire-progress><!-- Step X of N + progress --></div>3  <form data-questionnaire-step>4    <h3>Title</h3>5    <div data-field><label for="a">A</label><input id="a" name="a" required /></div>6    <footer>7      <button type="button" class="ghost" data-questionnaire-back>Back</button>8      <button type="submit">Continue</button>9    </footer>10  </form>11  <form data-questionnaire-step hidden></form>12</mo-questionnaire>

API

NAMEKINDDESCRIPTION
<mo-questionnaire>elementWizard orchestrator over form[data-questionnaire-step] children
[data-questionnaire-step]attributeOne wizard step (a plain form); hidden managed by JS
[data-questionnaire-progress]attributeSlot rendering Step X of N beside a native progress
[data-questionnaire-choices] / [data-questionnaire-choice]attributeChoice list and card; contains hidden input + indicator + label + shortcut
[data-questionnaire-error] / [data-questionnaire-input]attributeError slot and freeform input wrapper
data-start / data-resetattributeOpen on step N · clear and return to step 1 on completion
data-required / data-questionnaire-skipattributeRequire choice selection · skip button for optional steps
mo-questionnaire-completeelementEvent with detail.values (merged FormData); native reportValidity gates each advance

FILES

src/css/questionnaire.csssrc/js/questionnaire.js
Install:mo add questionnaire

THEMING · PLAYGROUND

This is the exact component from the examples above, wearing a completely different theme. Edit the tokens and --mo-* hooks in the editor — autocomplete knows them all — and the preview obeys in real time. Your CSS always wins.

Tokens & hooks — edit live
Global tokens
--accent--background--border--card--foreground--input--muted-foreground--primary--primary-foreground--radius--ring

Preview

What should the agent build next?

Pick one — Continue validates the choice.

Your CSS

Try it: type --mo- for the component hooks, or edit any value — the preview obeys in real time.