grasscnGitHub

Questionnaire

Ordered world setup with validation, choices and submission.

Preview

Choose a world mode
Loading example...
To run this copied example, install these items using the linked CLI or manual instructions:

Usage

Import the Questionnaire parts from @/components/ui/questionnaire. Declare ordered items on the root and matching QuestionnaireItem names, required flags and choices. The primary example uses required single-choice mode followed by a required text answer, then reads native FormData on submit.

Composition

Compose titles, choices/input, errors and navigation inside the root. QuestionnairePrevious, QuestionnaireNext, QuestionnaireSkip and QuestionnaireSubmit coordinate the primitive's active step. Set multiple on a choice step for checkbox answers; optional steps can be skipped. The retained world-setup playground includes optional multiple features and a freeform alternative. shortcuts="numbers" enables numbered choices.

API and accessibility

The installed primitive is pinned to @shadcn/react@0.3.1; do not substitute unrelated questionnaire APIs. The root ref is an HTMLFormElement and onSubmit receives the native form event. Text parts accept logical maxWidth and alignment, scale defaults to 2. Numbered navigation and the questionnaire arrangement are web adaptations; appearance claims apply only to recorded native constituents.

See the underlying API for shared semantics.

Installation

Loading registry address

Component source

This is the component implementation. Its supporting styles, helpers and resources are also required. See complete manual installation.

Component implementationcomponents/ui/questionnaire.tsx · tsx
"use client";

import { Questionnaire as Primitive } from "@shadcn/react/questionnaire";
import * as React from "react";

import { Button } from "./button";
import { Input } from "./input";
import { MinecraftProse } from "./minecraft-prose";
import { minecraftClasses as cn, minecraftStyle } from "./minecraft-render";
import { playMinecraftClick } from "./minecraft-sound";

import "./minecraft-checkbox.css";

Interactive playground

Question 1 of 3
Choose a world mode

Choose a mode or write another answer.

Use the keyboard or choose an option