Docs Components Forms

Questionnaire

React example follows below.
ts
const questionnaireFixture = {
id: "questionnaire",
shortcuts: "letters",
items: [
{
name: "working-style",
prompt: "How should this agent work?",
description: "Choose the level of autonomy that fits this project.",
required: true,
multiple: false,
choices: [
{
value: "guided",
label: "Ask before acting",
description: "Confirm each material change before continuing.",
},
{
value: "routine",
label: "Run routine steps",
description: "Proceed independently for safe, reversible work.",
},
{
value: "draft",
label: "Draft only",
description: "Prepare changes without applying them.",
},
],
},
{
name: "safeguards",
prompt: "Which safeguards should it apply?",
description: "Choose any that matter, or skip this step.",
required: false,
multiple: true,
skippable: true,
choices: [
{
value: "tests",
label: "Run focused tests",
description: "Verify changed behavior before handoff.",
},
{
value: "docs",
label: "Update documentation",
description: "Keep usage guidance aligned with the change.",
},
{
value: "review",
label: "Request a review",
description: "Pause for another person to inspect the result.",
},
],
},
{
name: "context",
prompt: "What context should it know?",
description: "Add one constraint, convention, or goal before submitting.",
required: true,
input: {
label: "Project context",
placeholder: "Constraints, conventions, or goals",
type: "text",
},
},
],
} as const;
import { Questionnaire } from "@grassroot/ui-react";
export default function QuestionnaireDemo() {
return (
<div className="w-full max-w-xl">
<Questionnaire items={questionnaireFixture.items} shortcuts={questionnaireFixture.shortcuts} />
</div>
);
}
ts
<script setup lang="ts">
const questionnaireFixture = {
id: "questionnaire",
shortcuts: "letters",
items: [
{
name: "working-style",
prompt: "How should this agent work?",
description: "Choose the level of autonomy that fits this project.",
required: true,
multiple: false,
choices: [
{
value: "guided",
label: "Ask before acting",
description: "Confirm each material change before continuing.",
},
{
value: "routine",
label: "Run routine steps",
description: "Proceed independently for safe, reversible work.",
},
{
value: "draft",
label: "Draft only",
description: "Prepare changes without applying them.",
},
],
},
{
name: "safeguards",
prompt: "Which safeguards should it apply?",
description: "Choose any that matter, or skip this step.",
required: false,
multiple: true,
skippable: true,
choices: [
{
value: "tests",
label: "Run focused tests",
description: "Verify changed behavior before handoff.",
},
{
value: "docs",
label: "Update documentation",
description: "Keep usage guidance aligned with the change.",
},
{
value: "review",
label: "Request a review",
description: "Pause for another person to inspect the result.",
},
],
},
{
name: "context",
prompt: "What context should it know?",
description: "Add one constraint, convention, or goal before submitting.",
required: true,
input: {
label: "Project context",
placeholder: "Constraints, conventions, or goals",
type: "text",
},
},
],
} as const;
import { Questionnaire } from "@grassroot/ui-vue";
</script>
<template>
<div class="w-full max-w-xl">
<Questionnaire
:items="questionnaireFixture.items"
:shortcuts="questionnaireFixture.shortcuts"
/>
</div>
</template>
ts
import { Component } from "@angular/core";
const questionnaireFixture = {
id: "questionnaire",
shortcuts: "letters",
items: [
{
name: "working-style",
prompt: "How should this agent work?",
description: "Choose the level of autonomy that fits this project.",
required: true,
multiple: false,
choices: [
{
value: "guided",
label: "Ask before acting",
description: "Confirm each material change before continuing.",
},
{
value: "routine",
label: "Run routine steps",
description: "Proceed independently for safe, reversible work.",
},
{
value: "draft",
label: "Draft only",
description: "Prepare changes without applying them.",
},
],
},
{
name: "safeguards",
prompt: "Which safeguards should it apply?",
description: "Choose any that matter, or skip this step.",
required: false,
multiple: true,
skippable: true,
choices: [
{
value: "tests",
label: "Run focused tests",
description: "Verify changed behavior before handoff.",
},
{
value: "docs",
label: "Update documentation",
description: "Keep usage guidance aligned with the change.",
},
{
value: "review",
label: "Request a review",
description: "Pause for another person to inspect the result.",
},
],
},
{
name: "context",
prompt: "What context should it know?",
description: "Add one constraint, convention, or goal before submitting.",
required: true,
input: {
label: "Project context",
placeholder: "Constraints, conventions, or goals",
type: "text",
},
},
],
} as const;
import { GrassrootQuestionnaire } from "@grassroot/ui-angular/questionnaire";
@Component({
selector: "app-questionnaire-demo",
standalone: true,
imports: [GrassrootQuestionnaire],
host: { style: "display: contents" },
template: `
<div class="w-full max-w-xl">
<grassroot-questionnaire [items]="fixture.items" [shortcuts]="fixture.shortcuts" />
</div>
`,
})
export class QuestionnaireDemoComponent {
protected readonly fixture = questionnaireFixture;
}
export default QuestionnaireDemoComponent;
ts
<script lang="ts">
const questionnaireFixture = {
id: "questionnaire",
shortcuts: "letters",
items: [
{
name: "working-style",
prompt: "How should this agent work?",
description: "Choose the level of autonomy that fits this project.",
required: true,
multiple: false,
choices: [
{
value: "guided",
label: "Ask before acting",
description: "Confirm each material change before continuing.",
},
{
value: "routine",
label: "Run routine steps",
description: "Proceed independently for safe, reversible work.",
},
{
value: "draft",
label: "Draft only",
description: "Prepare changes without applying them.",
},
],
},
{
name: "safeguards",
prompt: "Which safeguards should it apply?",
description: "Choose any that matter, or skip this step.",
required: false,
multiple: true,
skippable: true,
choices: [
{
value: "tests",
label: "Run focused tests",
description: "Verify changed behavior before handoff.",
},
{
value: "docs",
label: "Update documentation",
description: "Keep usage guidance aligned with the change.",
},
{
value: "review",
label: "Request a review",
description: "Pause for another person to inspect the result.",
},
],
},
{
name: "context",
prompt: "What context should it know?",
description: "Add one constraint, convention, or goal before submitting.",
required: true,
input: {
label: "Project context",
placeholder: "Constraints, conventions, or goals",
type: "text",
},
},
],
} as const;
import { Questionnaire } from "@grassroot/ui-svelte";
</script>
<div class="w-full max-w-xl">
<Questionnaire items={questionnaireFixture.items} shortcuts={questionnaireFixture.shortcuts} />
</div>
ts
/** @jsxImportSource solid-js */
const questionnaireFixture = {
id: "questionnaire",
shortcuts: "letters",
items: [
{
name: "working-style",
prompt: "How should this agent work?",
description: "Choose the level of autonomy that fits this project.",
required: true,
multiple: false,
choices: [
{
value: "guided",
label: "Ask before acting",
description: "Confirm each material change before continuing.",
},
{
value: "routine",
label: "Run routine steps",
description: "Proceed independently for safe, reversible work.",
},
{
value: "draft",
label: "Draft only",
description: "Prepare changes without applying them.",
},
],
},
{
name: "safeguards",
prompt: "Which safeguards should it apply?",
description: "Choose any that matter, or skip this step.",
required: false,
multiple: true,
skippable: true,
choices: [
{
value: "tests",
label: "Run focused tests",
description: "Verify changed behavior before handoff.",
},
{
value: "docs",
label: "Update documentation",
description: "Keep usage guidance aligned with the change.",
},
{
value: "review",
label: "Request a review",
description: "Pause for another person to inspect the result.",
},
],
},
{
name: "context",
prompt: "What context should it know?",
description: "Add one constraint, convention, or goal before submitting.",
required: true,
input: {
label: "Project context",
placeholder: "Constraints, conventions, or goals",
type: "text",
},
},
],
} as const;
import { Questionnaire } from "@grassroot/ui-solid";
import type { JSX } from "solid-js";
export default function QuestionnaireDemo(): JSX.Element {
return (
<div class="w-full max-w-xl">
<Questionnaire
items={questionnaireFixture.items}
shortcuts={questionnaireFixture.shortcuts}
/>
</div>
);
}

Installation

API Reference

Import

import { Questionnaire } from "@grassroot/ui-react";

Props

Prop
Type
Default
Requirement
Description
items
readonly QuestionnaireItem[]
required
item
string | undefined
optional
Controlled active item name.
defaultItem
string | undefined
optional
Initial active item for uncontrolled use.
answers
readonly QuestionnaireAnswer[] | undefined
optional
Controlled answers.
defaultAnswers
readonly QuestionnaireAnswer[] | undefined
optional
Initial answers for uncontrolled use and native reset.
shortcuts
QuestionnaireShortcutMode | undefined
optional
previousLabel
string | undefined
optional
nextLabel
string | undefined
optional
skipLabel
string | undefined
optional
submitLabel
string | undefined
optional
noValidate
boolean | undefined
true
optional
Disable native constraint validation; Questionnaire renders its own errors.
onItemChange
((item: string) => void) | undefined
optional
onAnswersChange
((answers: readonly QuestionnaireAnswer[]) => void) | undefined
optional
onSubmit
((answers: readonly QuestionnaireAnswer[], formData: FormData) => void) | undefined
optional
Prop
items
Type
readonly QuestionnaireItem[]
Default
Requirement
required
Description
Prop
item
Type
string | undefined
Default
Requirement
optional
Description
Controlled active item name.
Prop
defaultItem
Type
string | undefined
Default
Requirement
optional
Description
Initial active item for uncontrolled use.
Prop
answers
Type
readonly QuestionnaireAnswer[] | undefined
Default
Requirement
optional
Description
Controlled answers.
Prop
defaultAnswers
Type
readonly QuestionnaireAnswer[] | undefined
Default
Requirement
optional
Description
Initial answers for uncontrolled use and native reset.
Prop
shortcuts
Type
QuestionnaireShortcutMode | undefined
Default
Requirement
optional
Description
Prop
previousLabel
Type
string | undefined
Default
Requirement
optional
Description
Prop
nextLabel
Type
string | undefined
Default
Requirement
optional
Description
Prop
skipLabel
Type
string | undefined
Default
Requirement
optional
Description
Prop
submitLabel
Type
string | undefined
Default
Requirement
optional
Description
Prop
noValidate
Type
boolean | undefined
Default
true
Requirement
optional
Description
Disable native constraint validation; Questionnaire renders its own errors.
Prop
onItemChange
Type
((item: string) => void) | undefined
Default
Requirement
optional
Description
Prop
onAnswersChange
Type
((answers: readonly QuestionnaireAnswer[]) => void) | undefined
Default
Requirement
optional
Description
Prop
onSubmit
Type
((answers: readonly QuestionnaireAnswer[], formData: FormData) => void) | undefined
Default
Requirement
optional
Description

Events

EventPayload
onItemChange((item: string) => void) | undefined
onAnswersChange((answers: readonly QuestionnaireAnswer[]) => void) | undefined
onSubmit((answers: readonly QuestionnaireAnswer[], formData: FormData) => void) | undefined

Native attributes

Standard DOM and ARIA attributes not listed above spread onto the root element.

Import

import { Questionnaire } from "@grassroot/ui-vue";

Props

Prop
Type
Default
Requirement
items
readonly QuestionnaireItem[]
required
item
string | undefined
optional
defaultItem
string | undefined
optional
answers
readonly QuestionnaireAnswer[] | undefined
optional
defaultAnswers
readonly QuestionnaireAnswer[] | undefined
() => []
optional
shortcuts
QuestionnaireShortcutMode | undefined
optional
previousLabel
string | undefined
questionnaireDefaults.previousLabel
optional
nextLabel
string | undefined
questionnaireDefaults.nextLabel
optional
skipLabel
string | undefined
questionnaireDefaults.skipLabel
optional
submitLabel
string | undefined
questionnaireDefaults.submitLabel
optional
noValidate
boolean | undefined
true
optional
Prop
items
Type
readonly QuestionnaireItem[]
Default
Requirement
required
Prop
item
Type
string | undefined
Default
Requirement
optional
Prop
defaultItem
Type
string | undefined
Default
Requirement
optional
Prop
answers
Type
readonly QuestionnaireAnswer[] | undefined
Default
Requirement
optional
Prop
defaultAnswers
Type
readonly QuestionnaireAnswer[] | undefined
Default
() => []
Requirement
optional
Prop
shortcuts
Type
QuestionnaireShortcutMode | undefined
Default
Requirement
optional
Prop
previousLabel
Type
string | undefined
Default
questionnaireDefaults.previousLabel
Requirement
optional
Prop
nextLabel
Type
string | undefined
Default
questionnaireDefaults.nextLabel
Requirement
optional
Prop
skipLabel
Type
string | undefined
Default
questionnaireDefaults.skipLabel
Requirement
optional
Prop
submitLabel
Type
string | undefined
Default
questionnaireDefaults.submitLabel
Requirement
optional
Prop
noValidate
Type
boolean | undefined
Default
true
Requirement
optional

Events

EventPayload
update:item[item: string]
update:answers[answers: readonly QuestionnaireAnswer[]]
submit[answers: readonly QuestionnaireAnswer[], formData: FormData]

Import

import { Component } from "@angular/core";
import { GrassrootQuestionnaire } from "@grassroot/ui-angular/questionnaire";

Props

Prop
Type
Default
Requirement
items
readonly QuestionnaireItem[]
required
item
string
optional
defaultItem
string
optional
answers
readonly QuestionnaireAnswer[]
optional
defaultAnswers
readonly QuestionnaireAnswer[]
[]
optional
shortcuts
QuestionnaireShortcutMode
optional
previousLabel
string
questionnaireDefaults.previousLabel
optional
nextLabel
string
questionnaireDefaults.nextLabel
optional
skipLabel
string
questionnaireDefaults.skipLabel
optional
submitLabel
string
questionnaireDefaults.submitLabel
optional
noValidate
boolean
true
optional
className
string
optional
Prop
items
Type
readonly QuestionnaireItem[]
Default
Requirement
required
Prop
item
Type
string
Default
Requirement
optional
Prop
defaultItem
Type
string
Default
Requirement
optional
Prop
answers
Type
readonly QuestionnaireAnswer[]
Default
Requirement
optional
Prop
defaultAnswers
Type
readonly QuestionnaireAnswer[]
Default
[]
Requirement
optional
Prop
shortcuts
Type
QuestionnaireShortcutMode
Default
Requirement
optional
Prop
previousLabel
Type
string
Default
questionnaireDefaults.previousLabel
Requirement
optional
Prop
nextLabel
Type
string
Default
questionnaireDefaults.nextLabel
Requirement
optional
Prop
skipLabel
Type
string
Default
questionnaireDefaults.skipLabel
Requirement
optional
Prop
submitLabel
Type
string
Default
questionnaireDefaults.submitLabel
Requirement
optional
Prop
noValidate
Type
boolean
Default
true
Requirement
optional
Prop
className
Type
string
Default
Requirement
optional

Events

EventPayload
itemChangestring
answersChangereadonly QuestionnaireAnswer[]
submitQuestionnaireSubmitDetail

Import

import { Questionnaire } from "@grassroot/ui-svelte";

Props

Prop
Type
Default
Requirement
items
readonly QuestionnaireItem[]
required
item
string
optional
defaultItem
string
optional
answers
readonly QuestionnaireAnswer[]
optional
defaultAnswers
readonly QuestionnaireAnswer[]
optional
shortcuts
QuestionnaireShortcutMode
optional
previousLabel
string
optional
nextLabel
string
optional
skipLabel
string
optional
submitLabel
string
optional
noValidate
boolean
true
optional
onItemChange
(item: string) => void
optional
onAnswersChange
(answers: readonly QuestionnaireAnswer[]) => void
optional
onSubmit
(answers: readonly QuestionnaireAnswer[], formData: FormData) => void
optional
Prop
items
Type
readonly QuestionnaireItem[]
Default
Requirement
required
Prop
item
Type
string
Default
Requirement
optional
Prop
defaultItem
Type
string
Default
Requirement
optional
Prop
answers
Type
readonly QuestionnaireAnswer[]
Default
Requirement
optional
Prop
defaultAnswers
Type
readonly QuestionnaireAnswer[]
Default
Requirement
optional
Prop
shortcuts
Type
QuestionnaireShortcutMode
Default
Requirement
optional
Prop
previousLabel
Type
string
Default
Requirement
optional
Prop
nextLabel
Type
string
Default
Requirement
optional
Prop
skipLabel
Type
string
Default
Requirement
optional
Prop
submitLabel
Type
string
Default
Requirement
optional
Prop
noValidate
Type
boolean
Default
true
Requirement
optional
Prop
onItemChange
Type
(item: string) => void
Default
Requirement
optional
Prop
onAnswersChange
Type
(answers: readonly QuestionnaireAnswer[]) => void
Default
Requirement
optional
Prop
onSubmit
Type
(answers: readonly QuestionnaireAnswer[], formData: FormData) => void
Default
Requirement
optional
Prop
className
Type
string
Default
Requirement
optional

Events

EventPayload
onItemChange(item: string) => void
onAnswersChange(answers: readonly QuestionnaireAnswer[]) => void
onSubmit(answers: readonly QuestionnaireAnswer[], formData: FormData) => void

Import

import { Questionnaire } from "@grassroot/ui-solid";
import type { JSX } from "solid-js";

Props

Prop
Type
Default
Requirement
items
readonly QuestionnaireItem[]
required
item
string
optional
defaultItem
string
optional
answers
readonly QuestionnaireAnswer[]
optional
defaultAnswers
readonly QuestionnaireAnswer[]
optional
shortcuts
QuestionnaireShortcutMode
optional
previousLabel
string
optional
nextLabel
string
optional
skipLabel
string
optional
submitLabel
string
optional
noValidate
boolean
true
optional
onItemChange
(item: string) => void
optional
onAnswersChange
(answers: readonly QuestionnaireAnswer[]) => void
optional
onSubmit
(answers: readonly QuestionnaireAnswer[], formData: FormData) => void
optional
Prop
items
Type
readonly QuestionnaireItem[]
Default
Requirement
required
Prop
item
Type
string
Default
Requirement
optional
Prop
defaultItem
Type
string
Default
Requirement
optional
Prop
answers
Type
readonly QuestionnaireAnswer[]
Default
Requirement
optional
Prop
defaultAnswers
Type
readonly QuestionnaireAnswer[]
Default
Requirement
optional
Prop
shortcuts
Type
QuestionnaireShortcutMode
Default
Requirement
optional
Prop
previousLabel
Type
string
Default
Requirement
optional
Prop
nextLabel
Type
string
Default
Requirement
optional
Prop
skipLabel
Type
string
Default
Requirement
optional
Prop
submitLabel
Type
string
Default
Requirement
optional
Prop
noValidate
Type
boolean
Default
true
Requirement
optional
Prop
onItemChange
Type
(item: string) => void
Default
Requirement
optional
Prop
onAnswersChange
Type
(answers: readonly QuestionnaireAnswer[]) => void
Default
Requirement
optional
Prop
onSubmit
Type
(answers: readonly QuestionnaireAnswer[], formData: FormData) => void
Default
Requirement
optional
Prop
className
Type
string
Default
Requirement
optional

Events

EventPayload
onItemChange(item: string) => void
onAnswersChange(answers: readonly QuestionnaireAnswer[]) => void
onSubmit(answers: readonly QuestionnaireAnswer[], formData: FormData) => void