Skip to content

shadcn.io is an independent project built on shadcn/ui

AI Prompt Input Input Group for React

A prompt box with an Auto menu, a 52% used note, and a disabled send button under the textarea.

A prompt with a row under it. The row has an add button, an Auto menu with Agent and Manual, the text 52% used, and a round send button that stays disabled. Picking a mode does not change the Auto label.

Use it for a chat composer when the mode and the quota sit with the prompt. A plain multiline field is a Textarea. In React, Base UI does not enable send when the box has text.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.
Use email insteadNo credit card

Anatomy

Input Group anatomy: root, addon, input, text, button

Usage

<div className="flex w-full max-w-2xl flex-col gap-4">
  <InputGroup className="bg-background">
    <InputGroupTextarea
      aria-label="Prompt"
      placeholder="Ask, Search or Chat..."
    />
    <InputGroupAddon align="block-end">
      <InputGroupButton
        aria-label="Add context"
        pill
        size="icon-xs"
        variant="outline"
      >
        <PlusIcon aria-hidden="true" />
      </InputGroupButton>
      <DropdownMenu>
        <DropdownMenuTrigger render={<InputGroupButton variant="ghost" />}>
          Auto
        </DropdownMenuTrigger>
        <DropdownMenuContent
          align="start"
          className="[--radius:0.95rem]"
          side="top"
        >
          <DropdownMenuGroup>
            <DropdownMenuItem>Auto</DropdownMenuItem>
            <DropdownMenuItem>Agent</DropdownMenuItem>
            <DropdownMenuItem>Manual</DropdownMenuItem>
          </DropdownMenuGroup>
        </DropdownMenuContent>
      </DropdownMenu>
{/* The rest of the file is under Installation. */}

FAQ

How do I put the mode menu and send button under the prompt?

Put them in one InputGroupAddon with align="block-end", written after InputGroupTextarea. Block end places the addon under the textarea as a full-width row. ms-auto on the usage text pushes it, the separator and the send button to the end of the row.

How is the Auto, Agent and Manual menu built?

It's a Dropdown Menu with an InputGroupButton labeled Auto as its trigger. DropdownMenuTrigger renders the InputGroupButton through render. It opens above the toolbar. side="top" and align="start" on DropdownMenuContent place it. Picking Agent or Manual doesn't change the label: keep the mode in state and render it in the trigger.

Why is the send button round and disabled?

pill makes the icon-xs button round, and variant="default" fills it. It sets disabled. Enable it once the prompt has text. Its name is aria-label="Send", since it shows only the arrow.

What is the plus button on the left of the toolbar?

An outline, round InputGroupButton named Add context, for attaching files or other context. It has no action here: wire it to your own picker.

What does the 52% used label do?

It's an InputGroupText with fixed text. Render your real quota there. The vertical Separator next to it gets h-4! so it's a short divider rather than the row's full height.

Does clicking the toolbar focus the textarea?

A click on the addon's empty space focuses the first input in the group, and this group has a textarea, not an input, so nothing is focused. Clicks on its buttons stay on the buttons.

API Reference

Input Group

Sets aria-label="Prompt", placeholder="Ask, Search or Chat...", align="block-end", aria-label="Add context", pill and size="icon-xs". The rest is on the Input Group page.

Dropdown Menu

Sets align="start" and side="top". The rest is on the Dropdown Menu page.

Separator

Sets orientation="vertical". The rest is on the Separator page.