Layish

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. Submit shows a toast.

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

Installation

npx shadcn@latest add layishsieger/registry/ask

The CLI copies the block into your project. You own the source. Mount a root <Toaster /> from @/components/ui/sonner if you enable toastOnSubmit.

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}
      toastOnSubmit
      onResult={(result) => {
        // HITL: addToolOutput({ output: result })
      }}
    />
  )
}

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
19Select 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[]
onResult(result) => void
variant"card" | "plain""card"
toastOnSubmitbooleanfalse
reviewbooleanfalse
cancelbooleanfalse
shortcuts"numbers" | "letters" | false"numbers"
shortcutHintsbooleantrue
focusablebooleanfalse
focusPrioritynumber0
focusTriggersref[] | element[]
autoAdvanceDelaynumber380
item / onItemChangecontrolled navigation