Questionnaire
Guide a user through a multi-step form.
Examples
Guide a user through a multi-step form
React code
import {
Questionnaire,
Progress,
QuestionnaireStep,
Label,
Input,
Button,
} from "@accelerate/react/components";
export function Example() {
return (
<>
<Questionnaire>
<Progress data-acc-step-progress="" aria-label="Questionnaire progress"></Progress>
<QuestionnaireStep>
<legend>Request</legend>
<Label htmlFor="request-text">Request title</Label>
<Input id="request-text" name="title" required />
</QuestionnaireStep>
<QuestionnaireStep>
<legend>Review</legend>
<p>Confirm the request before submitting.</p>
</QuestionnaireStep>
<Button data-acc-step="previous" variant="outline">Previous</Button>
<Button data-acc-step="next">Next</Button>
<Button data-acc-step="submit" type="submit">Send request</Button>
</Questionnaire>
</>
);
}Angular code
import { Component } from "@angular/core";
import {
AccQuestionnaire,
AccProgress,
AccQuestionnaireStep,
AccLabel,
AccInput,
AccButton,
} from "@accelerate/angular/components";
@Component({
selector: "app-example",
imports: [
AccQuestionnaire,
AccProgress,
AccQuestionnaireStep,
AccLabel,
AccInput,
AccButton,
],
template: `
<form accQuestionnaire>
<progress accProgress data-acc-step-progress="" aria-label="Questionnaire progress"></progress>
<fieldset accQuestionnaireStep>
<legend>Request</legend>
<label accLabel for="request-text">Request title</label>
<input accInput id="request-text" name="title" required>
</fieldset>
<fieldset accQuestionnaireStep>
<legend>Review</legend>
<p>Confirm the request before submitting.</p>
</fieldset>
<button accButton data-acc-step="previous" variant="outline">Previous</button>
<button accButton data-acc-step="next">Next</button>
<button accButton data-acc-step="submit" type="submit">Send request</button>
</form>
`,
})
export class Example {}Installation
Source preview. The expanded component catalog is ahead of the public npm releases. To run these examples in your own application, use packages built from the SDK source used for the previews or a release that includes the APIs below.
- React
@accelerate/ui@0.4.0and@accelerate/react@0.4.0- Angular
@accelerate/ui@0.4.0and@accelerate/angular@0.2.0
Load @accelerate/ui/theme.css and put acc-theme on the app or the region using Accelerator components. See the framework setup guide for the theme and adapter conventions.
Usage
Compose QuestionnaireStep fieldsets with legends and native fields. Mark controls with data-acc-step="previous", "next", or "submit"; set Previous and Next to type="button". Add Progress with data-acc-step-progress for optional progress tracking.
Import the React component Questionnaire from @accelerate/react/components. For Angular, add AccQuestionnaire to the standalone component’s imports and use <form accQuestionnaire>.
Examples use these React parts: Questionnaire, Progress, QuestionnaireStep, Label, Input, Button. The Angular examples show the corresponding directives and template hosts.
API reference
- QuestionnaireStep
- Use fieldsets with legends for each step.
- data-acc-step
- Use previous, next, and submit. Previous and Next are type="button".
- Validation
- Required fields are checked before moving forward.