翻篇收录说明
翻篇网页快照

Prompt Input - shadcn/ui

https://ui.shadcn.com/docs/ai-elements/aria/prompt-input

最近抓取:2026-12-04 03:59:13(北京时间)

最近内容变化:2026-12-01 01:31:32(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

A message field with attachments and a send button.

正文摘录

SectionsIntroductionComponentsAI ElementsInstallationThemingCLITypesetSkillsRegistryChangelogComponentsAccordionAlertAlert DialogAspect RatioAttachmentAvatarBadgeBreadcrumbBubbleButtonButton GroupCalendarCardCarouselChartCheckboxCode BlockCollapsibleComboboxCommandContext MenuData TableDate PickerDialogDirectionDrawerDropdown MenuEmptyFieldHover CardInputInput GroupInput OTPItemKbdLabelMarkerMessageMessage ScrollerNative SelectPaginationPopoverProgressQuestionnaireRadio GroupResizableScroll AreaSelectSeparatorSheetSidebarSkeletonSliderSonnerSpinnerSwitchTableTabsTextareaToastToggleToggle GroupTooltipTraceTypographyAI ElementsIntroductionChain of ThoughtChatCheckpointConfirmationContextFile TreeInline CitationMessageModel SelectorPlanPrompt InputQueueReasoningSourcesStack TraceSubagentSuggestionTaskTerminalTest ResultsToolGet StartedInstallationcomponents.jsonPackage ImportsThemingTypesetDark ModeCLIMonorepoSkillsJavaScriptFigmallms.txtLegacy Docs@shadcn/reactMessage ScrollerQuestionnaire@shadcn/helpersAI SDKTanStack AIFormsReact Hook FormTanStack FormFormischUtilitiesscroll-fadeshimmerRegistryIntroductionGetting StartedGitHub RegistriesRegistry DirectoryRegistry HealthExamplesNamespacesAuthenticationDynamic SearchMCP ServerOpen in v0FAQAPI Referenceregistry.jsonregistry-item.jsonPrompt InputCopy PagePreviousNextA message field with attachments and a send button.Base UIReact AriaRadix UICopy"use client" import * as React from "react"View Code Prompt Input is the field the person types into to message the agent. It is an Input Group with a textarea, an attach button, the Model Selector menus and a send button. Attached files show as Attachment chips above the text. Installation Prompt Input is built with the Input Group, Attachment and Dropdown Menu components. CommandManualpnpmnpmyarnbunpnpm dlx shadcn@latest add input-group attachment dropdown-menuCopy Usage Copyimport { InputGroup, InputGroupAddon, InputGroupButton, InputGroupTextarea, } from "@/components/ui/input-group" Copy<form ref={formRef} onSubmit={onSubmit}> <InputGroup> <InputGroupTextarea value={text} onChange={(value) => setText(value)} placeholder="Ask the agent to change your code..." className="p-3" /> <InputGroupAddon align="block-end"> <InputGroupButton size="icon-sm" variant="outline" className="rounded-full" aria-label="Attach files" onPress={() => inputRef.current?.click()} > <PlusIcon /> </InputGroupButton> <InputGroupButton type="submit" size="icon-sm" variant="default" className="ml-auto rounded-full" isDisabled={!canSend} aria-label="Send" > <ArrowUpIcon /> </InputGroupButton> </InputGroupAddon> </InputGroup> </form> Attachments The attach button opens a hidden file input. Show each file as an Attachment in an addon with align="block-start", with a button to remove it. Model and Effort Put the two Model Selector menus in the block-end addon, between the attach and send buttons. Move ml-auto from the send button to the first menu trigger, so both menus sit next to the send button. Keyboard Enter sends the message. Shift+Enter adds a new line. CopyonKeyDown={(event) => { if (event.key === "Enter" && !event.shiftKey) { event.preventDefault() formRef.current?.requestSubmit() } }} AI SDK Send the text and the FileList from the file input. CopysendMessage({ text, files }) The route streams the reply with result.toUIMessageStreamResponse(). Migrating from AI SDK Elements If you added Prompt Input from AI SDK Elements, your project has a components/ai-elements/prompt-input.tsx wrapper. Paste this prompt into your coding agent to rebuild it on Input Group and Attachment. Every export keeps its name and props, so the code that uses it keeps working. PromptCopyMigrate components/ai-elements/prompt-input.tsx from AI SDK Elements to the shadcn/ui Input Group and Attachment components. Keep every export, with the same name and props, so the code that imports it keeps working. Only change how each part renders. 1. Install the components: npx shadcn@latest add input-group attachment 2. Read https://ui.shadcn.com/docs/ai-elements/aria/prompt-input.md and build Prompt Input the same way. 3. Rebuild each part: - PromptInput already renders an Input Group. Keep the form, the provider, the attachment state and the command parts as they are. - PromptInputTextarea renders an InputGroupTextarea with className="p-3". - PromptInputActionMenuTrigger renders an InputGroupButton with size="icon-sm", variant="outline" and rounded-full, with a PlusIcon. - PromptInputSubmit renders an InputGroupButton with size="icon-sm", variant="default" and rounded-full, with an ArrowUpIcon while idle. Keep the spinner and stop icons for the other statuses. - PromptInputHeader shows each attachment as an Attachment with size="sm" and a button to remove it. - Keep PromptInputSelect, PromptInputHoverCard and the tab parts as they are. 4. Remove the imports the file no longer uses. 5. Run the type checker and fix any errors.Expand PlanQueue On This PageInstallationUsageAttachmentsModel and EffortKeyboardAI SDKMigrating from AI SDK ElementsDeploy your shadcn/ui app on VercelTrusted by OpenAI, Sonos, Adobe, and more.Vercel provides tools and infrastructure to deploy apps and features at scale.Deploy NowDeploy to Vercel