Prompt Input

An input field that allows users to enter and submit text to an AI model.

Examples

Prompt Input basic

Prompt Input with actions

You can use PromptInputActions to add actions with tooltips to the PromptInput.

Installation

Copy and paste the following code into your project.

pnpm dlx shadcn-svelte@latest add https://ai-elements.vercel.app/r/prompt-kit-prompt-input.json

Component API

PromptInput

PropTypeDefaultDescription
isLoadingbooleanfalseLoading state of the input
valuestring""Controlled value of the input
onValueChange(value: string) => void-Callback when input value changes
maxHeightnumber | string240Maximum height of the textarea in pixels
onSubmit() => void-Callback when form is submitted (Enter pressed)
childrenSnippet-Child components to render
classNamestring-Additional CSS classes

PromptInputTextarea

PropTypeDefaultDescription
disableAutosizebooleanfalseDisable automatic height adjustment
classNamestring-Additional CSS classes
onKeyDown(e: KeyboardEvent) => void-Keyboard event handler
disabledbooleanfalseDisable the textarea input
...propsHTMLTextareaAttributes-All other textarea props are supported

PromptInputActions

PropTypeDefaultDescription
childrenSnippet-Child components to render
classNamestring-Additional CSS classes
...propsHTMLAttributes<HTMLDivElement>-All other div props are supported

PromptInputAction

PropTypeDefaultDescription
tooltipSnippet-Content to show in the tooltip
childrenSnippet-Child component to trigger the tooltip
classNamestring-Additional CSS classes for the tooltip
side"top" | "bottom" | "left" | "right""top"Position of the tooltip relative to the trigger
disabledbooleanfalseDisable the tooltip trigger
...propsTooltipProps-All other Tooltip component props are supported