Skip to content
SevenUI
Sign in
On this page

Questionnaire

Multi-step questionnaire flow built on the shadcn Questionnaire primitive.

Installation

Bash

Depends on the @shadcn/react package, installed automatically.

Usage

The root renders a real <form>: each QuestionnaireItem is a fieldset named question, progression and validation are managed internally, and answers arrive as FormData in onSubmit (use getAll for multiple items). Navigation buttons show and hide themselves — Next hides on the last step, Submit appears there, Skip only renders on non-required items.

API reference

Questionnaire

Extends form.

PropTypeDefault
defaultItemstring—
itemstring—
onItemChange(item: string) => void—
itemsreadonly QuestionnaireItemDefinition[]—
shortcuts"letters" | "numbers"—
onSubmitReact.FormEventHandler<HTMLFormElement>—

item/onItemChange control the active step externally (by item name); shortcuts enables keyboard selection and shows the shortcut chips on choices.

QuestionnaireItem

Extends fieldset. One question per item; only the active one is shown.

PropTypeDefault
namestring (required)—
multipleboolean — checkbox behavior instead of radiofalse
requiredbooleanfalse
invalidboolean — force invalid styling (external validation)—
onStatusChange(status: "unanswered" | "answered" | "skipped") => void—

QuestionnaireChoice

Extends label; the hidden input, indicator (radio dot / check), label, and shortcut chip are built in.

PropTypeDefault
valuestring (required)—
checked / defaultCheckedboolean—
disabledbooleanfalse
onChangeReact.ChangeEventHandler<HTMLInputElement>—

QuestionnaireInput

Freeform answer field for the active item.

PropTypeDefault
type"text" | "email" | "number" | "date" | "tel" | …"text"

QuestionnairePrevious, QuestionnaireSkip, QuestionnaireNext, QuestionnaireSubmit

Navigation buttons styled through Button’s variants (variant and size props apply; Previous/Skip default to outline). They disable and hide themselves based on position and item state. Default labels can be replaced via children.

QuestionnaireProgress, QuestionnaireTitle, QuestionnaireDescription, QuestionnaireChoiceDescription, QuestionnaireError, QuestionnaireActions

Presentation parts: progress (“x of y”, with { current, total, first, last } available via the render prop), the question heading (legend) and description, per-choice helper text, the validation message slot, and the action-row grid.

Was this page helpful?