Prompt Input
beui/prompt-inputFreeComponent
An auto-growing agent composer with prompt actions, model selection, keyboard submission, and animated send and stop states.
Install it
npx shadcn@latest add https://beui.dev/r/prompt-input.jsonSource
1"use client";2// beui.dev/components/agents/prompt-input34import { ArrowUp, Plus, Square } from "lucide-react";5import { AnimatePresence, motion, useReducedMotion } from "motion/react";6import {7 type FormEvent,8 type KeyboardEvent,9 type ReactNode,10 type TextareaHTMLAttributes,11 useCallback,12 useEffect,13 useLayoutEffect,14 useRef,15 useState,16} from "react";17import { Button } from "@/components/motion/button";18import {19 MorphPopover,20 MorphPopoverContent,21 MorphPopoverTrigger,22} from "@/components/motion/popover-morph";23import {24 Select,25 SelectContent,26 SelectItem,27 SelectTrigger,28} from "@/components/motion/select";29import { SPRING_SWAP } from "@/lib/ease";30import { cn } from "@/lib/utils";3132export interface PromptModel {33 value: string;34 label: ReactNode;35 icon?: ReactNode;36 disabled?: boolean;37}3839export interface PromptAction {40 value: string;41 label: ReactNode;42 description?: ReactNode;43 icon?: ReactNode;44 disabled?: boolean;45}4647export interface PromptInputProps extends Omit<48 TextareaHTMLAttributes<HTMLTextAreaElement>,49 "value" | "defaultValue" | "onChange" | "onSubmit" | "children"50> {51 value?: string;52 defaultValue?: string;53 onValueChange?: (value: string) => void;54 models?: PromptModel[];55 model?: string;56 defaultModel?: string;57 onModelChange?: (model: string) => void;58 actions?: PromptAction[];59 onAction?: (action: string) => void;60 onSubmit?: (value: string, model?: string) => void | Promise<void>;61 loading?: boolean;62 onStop?: () => void;63 minRows?: number;64 maxRows?: number;65 leadingAction?: ReactNode;66 className?: string;67}6869export function PromptInput({70 value,71 defaultValue = "",72 onValueChange,73 models = [],74 model,75 defaultModel,76 onModelChange,77 actions = [],78 onAction,79 onSubmit,80 loading = false,81 onStop,82 minRows = 2,83 maxRows = 8,84 leadingAction,85 className,86 disabled,87 placeholder = "Ask the agent to do something…",88 "aria-label": ariaLabel = "Prompt",89 onKeyDown,90 ...textareaProps91}: PromptInputProps) {92 const reduce = useReducedMotion() ?? false;93 const textareaRef = useRef<HTMLTextAreaElement>(null);94 const measurementRef = useRef<HTMLDivElement>(null);95 const [internalValue, setInternalValue] = useState(defaultValue);96 const [internalModel, setInternalModel] = useState(97 defaultModel ?? models[0]?.value,98 );99 const [actionsOpen, setActionsOpen] = useState(false);100 const currentValue = value ?? internalValue;101// … truncated
What it pulls in
npm packages
Files it writes
More from beui
All 104 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Action Swap Bluraction-swap-blur | beui | Components | Free | 3 deps · 4 files | |
| Action Swap Cascadeaction-swap-cascade | beui | Components | Free | 3 deps · 4 files | |
| Action Swap Rollaction-swap-roll | beui | Components | Free | 3 deps · 4 files | |
| Agent Activityagent-activity | beui | Components | Free | 4 deps · 9 files | |
| Agent Loading States Agent Progressagent-progress | beui | Components | Free | 3 deps · 3 files | |
| AI Sidebarai-sidebar | beui | Components | Free | 4 deps · 5 files | |
| Animated Badgeanimated-badge | beui | Components | Free | 4 deps · 3 files | |
| Number Animation Animated Numberanimated-number | beui | Components | Free | 3 deps · 3 files |
