Skip to content
kerfjsGitHub

Question

The run stops and asks you to choose before it carries on.

SourcePackage @kerf-js/veneer

Preview

tsx
import { state } from '@kerf-js/core'import { Question } from '@kerf-js/veneer'export function PickScope() {  const question = state<    typeof GAP & { answer?: string | string[] }  >(GAP)  return (    <Question      question={question.value}      quiet      onAnswer={(answer) =>        (question.value = { ...GAP, answer })      }    />  )}const GAP = {  id: 'scope',  prompt: 'Which regions should go back to d-4801?',  options: ['Only ap-south', 'Every region'],  free: true,}

Installation

npm install @kerf-js/veneer

Usage

tsx
import { Question } from '@kerf-js/veneer'

Several answers

A question with multiple set lets people pick more than one of its options.

tsx
import { state } from '@kerf-js/core'import { Question } from '@kerf-js/veneer'export function ManyAnswers() {  const question = state<    typeof NOTIFY & { answer?: string | string[] }  >(NOTIFY)  return (    <Question      question={question.value}      quiet      onAnswer={(answer) =>        (question.value = { ...NOTIFY, answer })      }    />  )}const NOTIFY = {  id: 'who',  prompt: 'Who should hear about the rollback?',  options: [    '#incidents',    'The on-call engineer',    'Everyone watching mobile-bff',  ],  multiple: true,}

Closed

The run stopped before anyone answered.

tsx
import { Question } from '@kerf-js/veneer'export function Closed() {  return (  <Question    question={{ ...GAP, closed: true }}    quiet  />  )}const GAP = {  id: 'scope',  prompt: 'Which regions should go back to d-4801?',  options: ['Only ap-south', 'Every region'],  free: true,}

When to use

Use it for

  • The assistant needs a decision, not just a yes

Reach for something else

Accessibility

  • It is a real fieldset with the question as its legend.
  • A new question is announced straight away unless quiet.

API Reference

PropTypeDefaultDescription
questionAgentQuestion—The prompt, options, and multiple, free, answer and closed.
quietbooleanfalseIt was there on load.
EventTypeDefaultDescription
onAnswer((answer: string | string[]) => void)—Continue was pressed.

RelatedTool callAssistant