Skip to content

AI Prompt Input

A compact prompt composer with keyboard shortcuts, async submit, and error states.

shadcn registry · install below

Shift + Enter for a new line
Local UI demo · no model connected

Installation

pnpm dlx shadcn@latest add https://www.sudhanshuxsingh.in/r/ai-prompt-input.json

Needs a project with shadcn/ui set up. The source lands in your codebase, ready to edit.

Usage

"use client";

import { AIPromptInput } from "@/components/ui/ai-prompt-input";

export function Example() {
  return (
    <AIPromptInput
      onSubmit={async (prompt) => {
        // Replace /api/chat with your own backend endpoint.
        const response = await fetch("/api/chat", {
          method: "POST",
          headers: { "Content-Type": "application/json" },
          body: JSON.stringify({ prompt }),
        });
        if (!response.ok) throw new Error("Request failed");
      }}
    />
  );
}