Skip to Content
NarakUI

Question Tool

The ask-user prompt. Takes over the composer card or sits inline as a transcript card.

Kinds

Single choice, multi choice, and free text. Choice prompts include an Other field unless allowCustomAnswer is false. A choice question with layout: 'grid' fills two columns with short, label-only options.

Single choice

Question
Which brand should this agent use?

Multi choice

Question
Which platforms should we monitor?

Free text

Question
What should the agent optimize for?

Two columns

Question
What type of work do you do?

States

A multi-step prompt, the compact prompt, the standalone card used in a transcript, and a completed card. compact replaces the footer with a header pager and a trailing Skip or Next; pass it to promptSlot on a compact composer. Once answered, the card shows a one-line summary. The composer variant has no summary; it stays disabled until the host removes it.

Multi-step

Questions
Which brand should this agent use?
1 of 3

Compact

Which brand should this agent use?
1 of 3

Ask a question…

Card

Question

Which brand should this agent use?

Completed card

Ramp

Installation

pnpm dlx shadcn@latest add @narakui/question-tool

Add "@narakui": "https://ui.narakcode.dev/r/{name}.json" to components.json, or install directly from https://ui.narakcode.dev/r/question-tool.json.

Usage

QuestionTool is presentational. Product chats own submit, skip, and multi-question navigation, then pass the result in. If a submit handler throws or rejects, the tool shows an error and keeps the answer editable.

import { Composer } from '@/components/ui/composer';
import { QuestionTool } from '@/components/ui/question-tool';

<Composer
  activeSlot={
    <QuestionTool
      variant="composer"
      questions={questions}
      onSubmitAnswer={handleAnswer}
    />
  }
/>

QuestionTool Properties

PropTypeDefaultDescription
questionsQuestionConfig[] (required)—Prompt list. Each item is single, multi, or text. See QuestionConfig below.
questionIndexnumber—1-based index when the host owns navigation. Omit to let the card step locally.
totalQuestionsnumberquestions.lengthProgress denominator. Defaults to questions.length.
toolCallIdstring—Resets local drafts when the host starts a new tool call.
answerQuestionAnswer—Completed answer from the host. Marks a single-question prompt done.
variant'card' | 'composer''card'composer fills the takeover slot. card is the inline transcript treatment.
compactbooleanfalseComposer only. A header pager and a trailing Skip/Next replace the footer, and choices start unselected.
disabledbooleanfalseDisables the prompt while host-owned work is still pending.
chatStatusstring—Host stream status. Disables the card variant while streaming. Ignored for composer.
allowSkipbooleantrueShows the skip action.
submitLabelstring'Submit'Primary action on the last question.
nextLabelstring'Next'Primary action on earlier questions in a multi-step prompt.
skipLabelstring'Skip'Skip action copy.
skippedLabelstring'Skipped'Summary text for a skipped question on a completed card.
onSubmitAnswer(answer: QuestionAnswer) => void | Promise<void>—Called with the last answer, or the only answer on a single prompt. May return a promise.
onSubmitAnswers(answers: QuestionAnswerMap) => void | Promise<void>—Called with every answer, keyed by 1-based index, when the last question in a multi-step prompt is submitted. May return a promise.
onNextQuestion() => void—Called when the user advances to the next question.
onPreviousQuestion() => void—Called when the user goes back a question.
renderComposerCounter(step: number, total: number) => ReactNode—Replaces the composer header's step counter on multi-step prompts.
classNamestring—Extra classes on the card frame.
choicesClassNamestring—Extra classes on the scrollable choices list, e.g. a scroll edge fade.
titlePlacement'header' | 'step''header'Where the composer variant shows the active question's title. step keeps it inside the animated step so it crossfades and resizes with the choices.

QuestionConfig

PropTypeDefaultDescription
kind'single' | 'multi' | 'text' (required)—Question type
titlestring (required)—Question text
idstring—Stable id for the question
optionsQuestionOption[]—Choices for single and multi questions. Each has id, label, and an optional description.
layout'list' | 'grid''list'Grid fills two columns top to bottom with short, label-only options; the Other field spans both. Described options always render as a list.
allowCustomAnswerbooleantrueShows the Other field. false submits only offered ids.
customLabelstring—Placeholder for the Other field when customPlaceholder is not set
customPlaceholderstring—Placeholder for the Other field
minSelectionsnumber1Fewest picks needed to submit
maxSelectionsnumber—Most picks allowed
rankedbooleanfalseMulti only. Picks are ranked in order and each badge shows its rank. With maxSelections, the rest lock once that many are picked.
initialSelectedIdsreadonly string[]—Ids selected when the question opens. Defaults to the first option; compact questions open empty.
placeholderstring—Placeholder for a text question