Uai

aiagent-question.tsx

Color theme

component · 06/112

Agent Question

Let an agent ask for a decision: single or multiple choice, a recommended option, Something else, number keys, and a record of the answers.

Install

Install manuallyView source on GitHub

Anatomy

  • AgentQuestion
  • AgentQuestionHeader
  • AgentQuestionItems
  • AgentQuestionItem
  • AgentQuestionTitle
  • AgentQuestionDescription
  • AgentQuestionOptions
  • AgentQuestionOption
  • AgentQuestionOther
  • AgentQuestionFooter
  • AgentQuestionSummary

Accessibility4 checks

  • Each question is a fieldset whose legend is the title. Single choice is a radio group with arrow keys; multiple choice is a labelled group of checkboxes.
  • Keys 1–9 pick the option at that position while focus is inside the question, except while typing in Something else; Enter continues. The groups expose aria-keyshortcuts and the visible key hints are hidden from assistive technology.
  • Focus moves to the new question's legend on each step and to the summary heading once answered, which is announced as “Answers sent”.
  • “Recommended” is part of the option's accessible name, and option descriptions are attached with aria-describedby.
canvasvariant="card"ai
AI and automation

Before I scaffold Kiln’s storefront I need three decisions.

Waiting for you
agent question variant

Code example

usage.tsx
"use client";import { RotateCcw } from "lucide-react";import { useEffect, useRef, useState } from "react";import { Button } from "@/components/ui/button";import {  AgentQuestion,  type AgentQuestionAnswers,  AgentQuestionDescription,  AgentQuestionFooter,  AgentQuestionHeader,  AgentQuestionItem,  AgentQuestionItems,  AgentQuestionOption,  AgentQuestionOptions,  AgentQuestionOther,  AgentQuestionSummary,  AgentQuestionTitle,  type AgentQuestionVariant,} from "@/components/ui/uai/agent-question";export function AgentQuestionPreview({ variant = "card" }: { variant?: AgentQuestionVariant }) {  const [round, setRound] = useState(0);  const [answered, setAnswered] = useState(false);  const timer = useRef<number | undefined>(undefined);  useEffect(() => () => window.clearTimeout(timer.current), []);  // Your agent receives the answers; the preview just waits a moment.  const send = (_answers: AgentQuestionAnswers) =>    new Promise<void>((resolve) => {      timer.current = window.setTimeout(() => {        setAnswered(true);        resolve();      }, 900);    });  return (    <div style={{ display: "grid", gap: 12, justifyItems: "start" }}>      <p className="m-0 text-[13px]/5 text-muted-foreground">        Before I scaffold Kiln’s storefront I need three decisions.      </p>      <AgentQuestion key={`${variant}-${round}`} variant={variant} onSubmit={send}>        <AgentQuestionHeader />        <AgentQuestionItems>          <AgentQuestionItem id="database" required>            <AgentQuestionTitle>Which database should I set up?</AgentQuestionTitle>            <AgentQuestionDescription>              I found a Prisma schema and a Drizzle config. Migrations will use the one you pick.            </AgentQuestionDescription>            <AgentQuestionOptions>              <AgentQuestionOption                value="postgres"                label="Postgres"                recommended                description="Matches DATABASE_URL in .env.example"              />              <AgentQuestionOption                value="sqlite"                label="SQLite"                description="Fastest for local work, no server to run"              />              <AgentQuestionOther />            </AgentQuestionOptions>          </AgentQuestionItem>          <AgentQuestionItem id="seed" type="multiple" required>            <AgentQuestionTitle>What should the seed data include?</AgentQuestionTitle>            <AgentQuestionDescription>Choose all that apply.</AgentQuestionDescription>            <AgentQuestionOptions>              <AgentQuestionOption                value="users"                label="Demo users"                description="3 accounts with fixed passwords"              />              <AgentQuestionOption                value="orders"                label="Sample orders"                description="40 orders across 2 months"              />              <AgentQuestionOther />            </AgentQuestionOptions>          </AgentQuestionItem>          <AgentQuestionItem id="auth">            <AgentQuestionTitle>Add auth now?</AgentQuestionTitle>            <AgentQuestionDescription>              You can add it later with one command.            </AgentQuestionDescription>            <AgentQuestionOptions>              <AgentQuestionOption value="password" label="Email and password" />              <AgentQuestionOption value="magic-link" label="Magic link" />              <AgentQuestionOption value="later" label="Not yet" />            </AgentQuestionOptions>          </AgentQuestionItem>        </AgentQuestionItems>        <AgentQuestionFooter />        <AgentQuestionSummary time="14:02" />      </AgentQuestion>      {answered ? (        <>          <p className="m-0 text-[13px]/5 text-foreground">            Setting up the database and seeding the storefront.          </p>          <Button            type="button"            variant="ghost"            size="sm"            onClick={() => {              setAnswered(false);              setRound((count) => count + 1);            }}          >            <RotateCcw aria-hidden="true" />            Ask again          </Button>        </>      ) : null}    </div>  );}

Manual installation

agent-question.tsx

Loading component source…

esc
ThinkingAI
MessageAI
CitationAI
AttachmentAI
Tool CallAI
Agent QuestionAI
Response StatusAI
Run SummaryAI
Context MeterAI
Conversation ThreadAI · Block
Research SessionAI · Block
File AnalysisAI · Block
Agent RunAI · Block
Approval CardFeedback
Empty StateFeedback
Status BannerFeedback
Progress SummaryFeedback
Inline FeedbackFeedback
Confirmation DialogFeedback
Activity TimelineFeedback
Skeleton GroupFeedback
Prompt ComposerForms
Form FieldForms
Search FieldForms
Filter BarForms
File UploadForms
Date Range PickerForms
Form Error SummaryForms
Unsaved Changes BarForms
Step IndicatorForms
Task ListData Display
Data Table ToolbarData Display
Metric CardData Display
Description ListData Display
Comparison TableData Display
Kanban BoardData Display
Calendar ViewData Display
Audit LogData Display
App HeaderNavigation
App SidebarNavigation
Breadcrumb TrailNavigation
Page TabsNavigation
Command MenuNavigation
Split PaneNavigation
Sign-in CardAuthentication
Sign-up CardAuthentication
Password RecoveryAuthentication
Code VerificationAuthentication · Block
Onboarding WizardAuthentication · Block
Workspace SetupAuthentication · Block
Coupon FieldCommerce
Quantity PickerCommerce
Cart ItemCommerce
Price SummaryCommerce
Order StatusCommerce
Product DetailCommerce · Block
Product ListingCommerce · Block
Cart DrawerCommerce · Block
CheckoutCommerce · Block
Order TrackingCommerce · Block
Subscription ManagementCommerce · Block
Announcement BarMarketing
Pricing ToggleMarketing
Testimonial CardMarketing
Product GalleryMarketing
Trust PanelMarketing
Newsletter FormMarketing
Hero SectionMarketing · Block
Feature ShowcaseMarketing · Block
Pricing SectionMarketing · Block
Testimonials SectionMarketing · Block
FAQ SectionMarketing · Block
Call to ActionMarketing · Block
Waitlist SectionMarketing · Block
Contact SectionMarketing · Block
Author CardContent
CommentContent
Reaction BarContent
Share MenuContent
Changelog EntryContent
Article PageContent · Block
Documentation PageContent · Block
Changelog PageContent · Block
Comment ThreadContent · Block
Community FeedContent · Block
Public ProfileContent · Block
Map FrameMaps
Map ControlsMaps
Map MarkerMaps
Map LegendMaps
Place CardMaps
Route SummaryMaps
Dashboard ShellApplication · Block
Settings PageApplication · Block
Profile PageApplication · Block
Team ManagementApplication · Block
Notification CenterApplication · Block
Billing PortalApplication · Block
Search ResultsApplication · Block
Resource ManagerOperations · Block
Data ExplorerOperations · Block
Import WorkflowOperations · Block
Approval QueueOperations · Block
Audit Log ViewerOperations · Block
Incident DashboardOperations · Block
Report BuilderOperations · Block
Document FieldBrazil
CEP FieldBrazil
Pix PaymentBrazil
Boleto PaymentBrazil
Installment PickerBrazil
Pix AutomáticoBrazil