Questionnaire
Questions an agent asks mid-run, one at a time, with answers that stay consistent.
When an agent needs a few answers before it goes on: one question at a time with choices, several picks or free text, an Other field, a review of every answer and Submit. Number keys pick, Enter moves on, Back keeps what you answered.
- Category
- AI Agent
- Access
- Free with an account
- Source
- 415 lines · one file
- States
- 5 drawn
- Added
- 13 Nov 2026
The decision inside it
An answer that no longer applies is cleared
When you change an answer and a later question no longer applies, it disappears and its answer is cleared, with a note saying so, instead of sending the agent an answer to a question you were never shown. The agent continues only when every required question is answered.
When to use it
Use Questionnaire when an agent needs a few structured answers before it continues: choices, several picks, free text, follow-ups that depend on earlier answers. For a single approval use Approval Request; for a long form use Field and Stepper.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Liro's Questionnaire for this.
Install it: npx shadcn@latest add @liro/questionnaire
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/questionnaire.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Free components install through the @liro registry with your CLI token: see the Namespaced tab.
Usage
import { Questionnaire, type Answers, type Question } from "@/components/ui/questionnaire";
const QUESTIONS: Question[] = [
{ id: "term", prompt: "Which term?", type: "single", options: [{ value: "12", label: "12 months" }, { value: "24", label: "24 months" }] },
{ id: "discount", prompt: "Discount for 24 months?", type: "single", showIf: { question: "term", anyOf: ["24"] }, options: [{ value: "0", label: "None" }, { value: "5", label: "5%" }], allowOther: true },
];
export function AgentQuestions({ send }: { send: (answers: Answers) => Promise<void> }) {
return <Questionnaire title="Before I draft the renewal" from="Renewal agent" questions={QUESTIONS} onSubmit={send} />;
}API reference
“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Type | Notes | ||
|---|---|---|---|
questions | Question[] | Yes | – |
title | string | No | What the agent is about to do: "Before I draft the renewal". |
from | string | No | Who asks: the agent's name. |
defaultAnswers | Answers | No | – |
onSubmit | (answers: Answers) => void | Promise<void> | No | Sends the answers that apply. May return a promise; a rejection keeps everything and shows inline. |
defaultReview | boolean | No | Start on the review step. |
defaultStep | number | No | Start on this question (index among the ones that apply). |
Dependencies
npm packages
clsxframer-motionlucide-reacttailwind-mergeLiro foundations, installed alongside it
liro-themebuttonStates
All of them are drawn by the component. None is left for you to design.
- Asking
- Follow-up question
- Review
- Sent
- Submit fails
Accessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances