Ask

A questionnaire wrap with review, cancel, auto-advance, and HITL-shaped results for AI SDK addToolOutput.

Built on shadcn Questionnaire. Distributed as a shadcn registry block from GitHub.

Default

Click the preview chrome or the card to focus. Hold ⌘/Ctrl for inline Kbd. Preview toasts on submit via host onSubmit.

Open in
Which direction?
1/2
Use Next to continue.

Installation

pnpm dlx shadcn@latest add layishsieger/registry/ask

The CLI copies the block into your project. You own the source.

Usage

import { Ask } from "@/components/ask"

const items = [
  {
    name: "direction",
    title: "Which direction?",
    required: true,
    choices: [
      {
        value: "clarify",
        label: "Ask a clarifying question",
        description: "Gather missing context before writing.",
      },
      {
        value: "draft",
        label: "Draft a first version",
        description: "Produce a starting point to iterate on.",
      },
    ],
  },
]

export function Example() {
  return (
    <Ask
      items={items}
      onSubmit={async (result) => {
        // Host owns post-submit (toast, remount, chat bubble, …).
        // Return a Promise to keep Submit pending until it settles.
        await persistAnswers(result)
      }}
      onResult={(result) => {
        // HITL: addToolOutput({ output: result })
      }}
    />
  )
}

onSubmit is optional and host-owned. It receives the submitted AskResult and may return a Promise — Submit stays pending until that settles. Ask does not toast or auto-reset; call toast (or remount) from the host if you want that.

onResult is the HITL payload. Submit returns { status: "submitted", answers }. Cancel returns { status: "canceled" }. Pass that object to addToolOutput({ output }).

Variants

variant="plain" drops the card background and uses bordered answer rows (Questionnaire look). Choice description adds optional subtext under each label.

What should the agent build next?
1/2
Choose a direction or describe another task.

Auto-advance

First pick auto-advances. Other Enter commits and advances. After Back, Next comes back.

Which direction?
1/3
First pick auto-advances. Other commits on Enter.

Review

Set review on the batch. Last-slide auto-advance and Other commit go to review, not submit.

Which direction?
1/2
First pick auto-advances. Other commits on Enter.

Cancel

Set cancel on the batch. Confirm before discarding answers.

1/2
Which direction?
First pick auto-advances. Other commits on Enter.

Keyboard

ShortcutAction
Previous / leave review
Next or Skip
Continue / Submit
1–9Select choice (or A–Z when shortcuts="letters")
/Move choice focus

Hold ⌘ (Command / Meta) or Ctrl to reveal those navigation shortcuts as inline Kbd chips on Previous / Skip / Next / Submit when shortcutHints is enabled (default). Set shortcuts={false} to disable answer keys and hints, or shortcutHints={false} to keep bindings without the hold-to-reveal chips. Choice keys stay as row badges. With focusable, shortcuts only run while the card is interactively focused — click the card or its focus surface, and use Tab to move between cards in an InteractiveFocusProvider.

AI SDK HITL

onResult is the tool output. The host passes it to addToolOutput.

1/2
Which direction?
First pick auto-advances. Other commits on Enter.

API

Ask

PropTypeDefault
itemsAskItem[]—
onSubmit(result) => void | Promise<void>—
onResult(result) => void—
variant"card" | "plain""card"
reviewbooleanfalse
cancelbooleanfalse
shortcuts"numbers" | "letters" | false"numbers"
shortcutHintsbooleantrue
focusablebooleanfalse
focusPrioritynumber0
focusTriggersref[] | element[]—
autoAdvanceDelaynumber380
item / onItemChangecontrolled navigation—