Theme
Customize appearance
Components
Questionnaire
Guide a user through a structured set of questions.
View component source ↗Preview
A minimal example to get started.
Installation
Install this component and its dependencies in a project initialized with shadcn.
pnpm dlx shadcn@latest add https://ui.hyunjoon.net/r/questionnaire.jsonUsage
This is the basic example. Use the Code tab above for the selected example. Adjust import aliases to match your project.
import { useState } from "react";
import {
Questionnaire,
QuestionnaireItem,
QuestionnaireTitle,
QuestionnaireDescription,
QuestionnaireChoices,
QuestionnaireChoice,
QuestionnaireSubmit,
QuestionnaireActions,
} from "@/components/ui/questionnaire";
export default function Example() {
const [submitted, setSubmitted] = useState(false);
return (
<div className="w-full max-w-sm">
<Questionnaire
items={[{ name: "role", choices: [{ value: "design" }, { value: "engineering" }] }]}
onSubmit={(event) => {
event.preventDefault();
setSubmitted(true);
}}
>
<QuestionnaireItem name="role">
<QuestionnaireTitle>What do you work on?</QuestionnaireTitle>
<QuestionnaireDescription>Select your primary focus.</QuestionnaireDescription>
<QuestionnaireChoices>
<QuestionnaireChoice value="design">Design</QuestionnaireChoice>
<QuestionnaireChoice value="engineering">Engineering</QuestionnaireChoice>
</QuestionnaireChoices>
</QuestionnaireItem>
<QuestionnaireActions>
<QuestionnaireSubmit>Finish</QuestionnaireSubmit>
</QuestionnaireActions>
</Questionnaire>
{submitted && (
<p role="status" className="mt-3 text-sm">
Thank you for your answer.
</p>
)}
</div>
);
}
API reference
Derived from the installed component types. Native DOM props are also supported where applicable. A dash means no explicit default is documented. Some props depend on the selected mode.
Questionnaire
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
ref | React.Ref<HTMLFormElement> | undefinedReact.Ref<HTMLFormElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLFormElement> | undefinedReact.FocusEventHandler<HTMLFormElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLFormElement> | undefinedReact.FocusEventHandler<HTMLFormElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLFormElement, Element> | undefinedReact.ChangeEventHandler<HTMLFormElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLFormElement> | undefinedReact.KeyboardEventHandler<HTMLFormElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLFormElement> | undefinedReact.MouseEventHandler<HTMLFormElement> | undefined | — | Called when the element is activated. |
name | string | undefinedstring | undefined | — | Field name used in form data. |
target | string | undefinedstring | undefined | — | Browsing context in which the link opens. |
defaultItem | string | undefinedstring | undefined | — | Question displayed initially. |
item | string | undefinedstring | undefined | — | Active question name when controlled. |
items | readonly QuestionnaireItemDefinition[] | undefinedreadonly QuestionnaireItemDefinition[] | undefined | — | Available options or item definitions. |
onItemChange | ((item: string) => void) | undefined((item: string) => void) | undefined | — | Called when the active question changes. |
shortcuts | QuestionnaireShortcutMode | undefinedQuestionnaireShortcutMode | undefined | — | Keyboard shortcut scheme for questionnaire choices. |
QuestionnaireActions
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLDivElement> | undefinedReact.Ref<HTMLDivElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLDivElement> | undefinedReact.FocusEventHandler<HTMLDivElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLDivElement> | undefinedReact.FocusEventHandler<HTMLDivElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLDivElement, Element> | undefinedReact.ChangeEventHandler<HTMLDivElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLDivElement> | undefinedReact.KeyboardEventHandler<HTMLDivElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLDivElement> | undefinedReact.MouseEventHandler<HTMLDivElement> | undefined | — | Called when the element is activated. |
QuestionnaireChoice
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
ref | React.Ref<HTMLLabelElement> | undefinedReact.Ref<HTMLLabelElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLLabelElement> | undefinedReact.FocusEventHandler<HTMLLabelElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLLabelElement> | undefinedReact.FocusEventHandler<HTMLLabelElement> | undefined | — | Called when the control loses focus. |
onKeyDown | React.KeyboardEventHandler<HTMLLabelElement> | undefinedReact.KeyboardEventHandler<HTMLLabelElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLLabelElement> | undefinedReact.MouseEventHandler<HTMLLabelElement> | undefined | — | Called when the element is activated. |
render | RenderProp<QuestionnaireChoiceState> | undefinedRenderProp<QuestionnaireChoiceState> | undefined | — | Element or render function used to compose a custom root element. |
htmlFor | string | undefinedstring | undefined | — | ID of the associated form control. |
checked | boolean | undefinedboolean | undefined | — | Current checked state when controlled. |
disabled | boolean | undefinedboolean | undefined | — | Prevents user interaction. |
onChange | React.ChangeEventHandler<HTMLInputElement, Element> | undefinedReact.ChangeEventHandler<HTMLInputElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
valueRequired | stringstring | — | The current value when controlled by the application. |
QuestionnaireChoiceDescription
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLSpanElement> | undefinedReact.Ref<HTMLSpanElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLSpanElement> | undefinedReact.FocusEventHandler<HTMLSpanElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLSpanElement> | undefinedReact.FocusEventHandler<HTMLSpanElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLSpanElement, Element> | undefinedReact.ChangeEventHandler<HTMLSpanElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLSpanElement> | undefinedReact.KeyboardEventHandler<HTMLSpanElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLSpanElement> | undefinedReact.MouseEventHandler<HTMLSpanElement> | undefined | — | Called when the element is activated. |
QuestionnaireChoices
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLDivElement> | undefinedReact.Ref<HTMLDivElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLDivElement> | undefinedReact.FocusEventHandler<HTMLDivElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLDivElement> | undefinedReact.FocusEventHandler<HTMLDivElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLDivElement, Element> | undefinedReact.ChangeEventHandler<HTMLDivElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLDivElement> | undefinedReact.KeyboardEventHandler<HTMLDivElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLDivElement> | undefinedReact.MouseEventHandler<HTMLDivElement> | undefined | — | Called when the element is activated. |
render | RenderProp<QuestionnaireChoicesState> | undefinedRenderProp<QuestionnaireChoicesState> | undefined | — | Element or render function used to compose a custom root element. |
QuestionnaireDescription
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLParagraphElement> | undefinedReact.Ref<HTMLParagraphElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLParagraphElement> | undefinedReact.FocusEventHandler<HTMLParagraphElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLParagraphElement> | undefinedReact.FocusEventHandler<HTMLParagraphElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLParagraphElement, Element> | undefinedReact.ChangeEventHandler<HTMLParagraphElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLParagraphElement> | undefinedReact.KeyboardEventHandler<HTMLParagraphElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLParagraphElement> | undefinedReact.MouseEventHandler<HTMLParagraphElement> | undefined | — | Called when the element is activated. |
render | RenderProp<RenderState> | undefinedRenderProp<RenderState> | undefined | — | Element or render function used to compose a custom root element. |
QuestionnaireError
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLParagraphElement> | undefinedReact.Ref<HTMLParagraphElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLParagraphElement> | undefinedReact.FocusEventHandler<HTMLParagraphElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLParagraphElement> | undefinedReact.FocusEventHandler<HTMLParagraphElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLParagraphElement, Element> | undefinedReact.ChangeEventHandler<HTMLParagraphElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLParagraphElement> | undefinedReact.KeyboardEventHandler<HTMLParagraphElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLParagraphElement> | undefinedReact.MouseEventHandler<HTMLParagraphElement> | undefined | — | Called when the element is activated. |
render | RenderProp<Pick<QuestionnaireItemState, "invalid">> | undefinedRenderProp<Pick<QuestionnaireItemState, "invalid">> | undefined | — | Element or render function used to compose a custom root element. |
QuestionnaireInput
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
ref | React.Ref<HTMLInputElement> | undefinedReact.Ref<HTMLInputElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLInputElement> | undefinedReact.FocusEventHandler<HTMLInputElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLInputElement> | undefinedReact.FocusEventHandler<HTMLInputElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLInputElement, HTMLInputElement> | undefinedReact.ChangeEventHandler<HTMLInputElement, HTMLInputElement> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLInputElement> | undefinedReact.KeyboardEventHandler<HTMLInputElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLInputElement> | undefinedReact.MouseEventHandler<HTMLInputElement> | undefined | — | Called when the element is activated. |
disabled | boolean | undefinedboolean | undefined | — | Prevents user interaction. |
value | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | The current value when controlled by the application. |
render | RenderProp<QuestionnaireInputState> | undefinedRenderProp<QuestionnaireInputState> | undefined | — | Element or render function used to compose a custom root element. |
alt | string | undefinedstring | undefined | — | Accessible text alternative for the image. |
src | string | undefinedstring | undefined | — | URL of the displayed resource. |
multiple | boolean | undefinedboolean | undefined | — | Allows more than one value to be selected. |
max | string | number | undefinedstring | number | undefined | — | Maximum allowed value. |
min | string | number | undefinedstring | number | undefined | — | Minimum allowed value. |
step | string | number | undefinedstring | number | undefined | — | Increment between valid values. |
required | boolean | undefinedboolean | undefined | — | Whether the user must provide a value before form submission. |
checked | boolean | undefinedboolean | undefined | — | Current checked state when controlled. |
maxLength | number | undefinednumber | undefined | — | Maximum number of input characters. |
placeholder | string | undefinedstring | undefined | — | Hint shown when the control has no value. |
type | QuestionnaireInputType | undefinedQuestionnaireInputType | undefined | — | The native input or button behavior. |
QuestionnaireItem
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
ref | React.Ref<HTMLFieldSetElement> | undefinedReact.Ref<HTMLFieldSetElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLFieldSetElement> | undefinedReact.FocusEventHandler<HTMLFieldSetElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLFieldSetElement> | undefinedReact.FocusEventHandler<HTMLFieldSetElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLFieldSetElement, Element> | undefinedReact.ChangeEventHandler<HTMLFieldSetElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLFieldSetElement> | undefinedReact.KeyboardEventHandler<HTMLFieldSetElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLFieldSetElement> | undefinedReact.MouseEventHandler<HTMLFieldSetElement> | undefined | — | Called when the element is activated. |
disabled | boolean | undefinedboolean | undefined | — | Prevents user interaction. |
invalid | boolean | undefinedboolean | undefined | — | Marks this item or value as invalid. |
nameRequired | stringstring | — | Field name used in form data. |
multiple | boolean | undefinedboolean | undefined | — | Allows more than one value to be selected. |
onStatusChange | ((status: QuestionnaireItemStatus) => void) | undefined((status: QuestionnaireItemStatus) => void) | undefined | — | Called when the answer status changes. |
required | boolean | undefinedboolean | undefined | — | Whether the user must provide a value before form submission. |
QuestionnaireNext
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLButtonElement> | undefinedReact.Ref<HTMLButtonElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
disabled | boolean | undefinedboolean | undefined | — | Prevents user interaction. |
name | string | undefinedstring | undefined | — | Field name used in form data. |
type | "button" | "submit" | "reset" | undefined"button" | "submit" | "reset" | undefined | — | The native input or button behavior. |
value | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | The current value when controlled by the application. |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLButtonElement> | undefinedReact.FocusEventHandler<HTMLButtonElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLButtonElement> | undefinedReact.FocusEventHandler<HTMLButtonElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLButtonElement, Element> | undefinedReact.ChangeEventHandler<HTMLButtonElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLButtonElement> | undefinedReact.KeyboardEventHandler<HTMLButtonElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLButtonElement> | undefinedReact.MouseEventHandler<HTMLButtonElement> | undefined | — | Called when the element is activated. |
render | RenderProp<QuestionnaireNavigationState> | undefinedRenderProp<QuestionnaireNavigationState> | undefined | — | Element or render function used to compose a custom root element. |
variant | "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined"link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined | "default" | Visual treatment of the component. |
size | "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undef…"default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined | "default" | Visual size of the component. |
QuestionnairePrevious
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLButtonElement> | undefinedReact.Ref<HTMLButtonElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
disabled | boolean | undefinedboolean | undefined | — | Prevents user interaction. |
name | string | undefinedstring | undefined | — | Field name used in form data. |
type | "button" | "submit" | "reset" | undefined"button" | "submit" | "reset" | undefined | — | The native input or button behavior. |
value | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | The current value when controlled by the application. |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLButtonElement> | undefinedReact.FocusEventHandler<HTMLButtonElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLButtonElement> | undefinedReact.FocusEventHandler<HTMLButtonElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLButtonElement, Element> | undefinedReact.ChangeEventHandler<HTMLButtonElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLButtonElement> | undefinedReact.KeyboardEventHandler<HTMLButtonElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLButtonElement> | undefinedReact.MouseEventHandler<HTMLButtonElement> | undefined | — | Called when the element is activated. |
render | RenderProp<QuestionnaireNavigationState> | undefinedRenderProp<QuestionnaireNavigationState> | undefined | — | Element or render function used to compose a custom root element. |
variant | "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined"link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined | "outline" | Visual treatment of the component. |
size | "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undef…"default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined | "default" | Visual size of the component. |
QuestionnaireProgress
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLDivElement> | undefinedReact.Ref<HTMLDivElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLDivElement> | undefinedReact.FocusEventHandler<HTMLDivElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLDivElement> | undefinedReact.FocusEventHandler<HTMLDivElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLDivElement, Element> | undefinedReact.ChangeEventHandler<HTMLDivElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLDivElement> | undefinedReact.KeyboardEventHandler<HTMLDivElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLDivElement> | undefinedReact.MouseEventHandler<HTMLDivElement> | undefined | — | Called when the element is activated. |
render | RenderProp<QuestionnaireRootState> | undefinedRenderProp<QuestionnaireRootState> | undefined | — | Element or render function used to compose a custom root element. |
QuestionnaireSkip
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLButtonElement> | undefinedReact.Ref<HTMLButtonElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
disabled | boolean | undefinedboolean | undefined | — | Prevents user interaction. |
name | string | undefinedstring | undefined | — | Field name used in form data. |
type | "button" | "submit" | "reset" | undefined"button" | "submit" | "reset" | undefined | — | The native input or button behavior. |
value | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | The current value when controlled by the application. |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLButtonElement> | undefinedReact.FocusEventHandler<HTMLButtonElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLButtonElement> | undefinedReact.FocusEventHandler<HTMLButtonElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLButtonElement, Element> | undefinedReact.ChangeEventHandler<HTMLButtonElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLButtonElement> | undefinedReact.KeyboardEventHandler<HTMLButtonElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLButtonElement> | undefinedReact.MouseEventHandler<HTMLButtonElement> | undefined | — | Called when the element is activated. |
render | RenderProp<QuestionnaireNavigationState> | undefinedRenderProp<QuestionnaireNavigationState> | undefined | — | Element or render function used to compose a custom root element. |
variant | "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined"link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined | "outline" | Visual treatment of the component. |
size | "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undef…"default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined | "default" | Visual size of the component. |
QuestionnaireSubmit
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLButtonElement> | undefinedReact.Ref<HTMLButtonElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
disabled | boolean | undefinedboolean | undefined | — | Prevents user interaction. |
name | string | undefinedstring | undefined | — | Field name used in form data. |
type | "button" | "submit" | "reset" | undefined"button" | "submit" | "reset" | undefined | — | The native input or button behavior. |
value | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | The current value when controlled by the application. |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLButtonElement> | undefinedReact.FocusEventHandler<HTMLButtonElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLButtonElement> | undefinedReact.FocusEventHandler<HTMLButtonElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLButtonElement, Element> | undefinedReact.ChangeEventHandler<HTMLButtonElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLButtonElement> | undefinedReact.KeyboardEventHandler<HTMLButtonElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLButtonElement> | undefinedReact.MouseEventHandler<HTMLButtonElement> | undefined | — | Called when the element is activated. |
render | RenderProp<QuestionnaireNavigationState> | undefinedRenderProp<QuestionnaireNavigationState> | undefined | — | Element or render function used to compose a custom root element. |
variant | "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined"link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined | "default" | Visual treatment of the component. |
size | "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undef…"default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined | "default" | Visual size of the component. |
QuestionnaireTitle
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLLegendElement> | undefinedReact.Ref<HTMLLegendElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLLegendElement> | undefinedReact.FocusEventHandler<HTMLLegendElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLLegendElement> | undefinedReact.FocusEventHandler<HTMLLegendElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLLegendElement, Element> | undefinedReact.ChangeEventHandler<HTMLLegendElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLLegendElement> | undefinedReact.KeyboardEventHandler<HTMLLegendElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLLegendElement> | undefinedReact.MouseEventHandler<HTMLLegendElement> | undefined | — | Called when the element is activated. |
render | RenderProp<RenderState> | undefinedRenderProp<RenderState> | undefined | — | Element or render function used to compose a custom root element. |
Usage notes
Declare stable item names and choice values. Handle submission in your application and keep required questions clearly identified.