- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Code Block
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Form
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Kbd
- Label
- Marker
- Menubar
- Message
- Message Scroller
- Native Select
- Navigation Menu
- Number Field
- Pagination
- Pin Input
- Popover
- Progress
- Questionnaire
- Radio Group
- Range Calendar
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Stepper
- Switch
- Table
- Tabs
- Tags Input
- Textarea
- Toast
- Toggle
- Toggle Group
- Tooltip
- Trace
- Typography
<script setup lang="ts">
import {
ArrowUpIcon,
ChevronDownIcon,
FileTextIcon,
PlusIcon,
XIcon,
} from '@lucide/vue'
import { useFileDialog } from '@vueuse/core'
import { computed, ref } from 'vue'
import {
Attachment,
AttachmentAction,
AttachmentActions,
AttachmentContent,
AttachmentMedia,
AttachmentTitle,
} from '@/components/ui/attachment'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuLabel,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu'
import {
InputGroup,
InputGroupAddon,
InputGroupButton,
InputGroupTextarea,
} from '@/components/ui/input-group'
interface AttachmentFile {
id: string
name: string
}
const providers = [
{
name: 'OpenAI',
models: [
{ id: 'gpt-5', name: 'GPT-5' },
{ id: 'gpt-5-mini', name: 'GPT-5 mini' },
],
},
{
name: 'Anthropic',
models: [
{ id: 'claude-sonnet-4-5', name: 'Claude Sonnet 4.5' },
{ id: 'claude-haiku-4-5', name: 'Claude Haiku 4.5' },
],
},
]
const models = providers.flatMap(provider => provider.models)
const efforts = [
{ id: 'low', name: 'Low' },
{ id: 'medium', name: 'Medium' },
{ id: 'high', name: 'High' },
]
const text = ref('')
const files = ref<AttachmentFile[]>([])
const model = ref(models[0]!.id)
const effort = ref(efforts[1]!.id)
const formRef = ref<HTMLFormElement | null>(null)
const currentModel = computed(() => models.find(item => item.id === model.value) ?? models[0]!)
const currentEffort = computed(() => efforts.find(item => item.id === effort.value) ?? efforts[1]!)
const canSend = computed(() => text.value.trim().length > 0)
function onSubmit() {
if (!canSend.value)
return
text.value = ''
files.value = []
}
// `reset` clears the dialog's input on open, so the same file can be picked again.
const fileDialog = useFileDialog({ multiple: true, reset: true })
fileDialog.onChange((selected) => {
if (!selected)
return
files.value = [
...files.value,
...Array.from(selected, file => ({
id: crypto.randomUUID(),
name: file.name,
})),
]
})
function removeFile(id: string) {
files.value = files.value.filter(item => item.id !== id)
}
function onKeydown(event: KeyboardEvent) {
if (event.key === 'Enter' && !event.shiftKey) {
event.preventDefault()
formRef.value?.requestSubmit()
}
}
</script>
<template>
<div class="mx-auto w-full max-w-lg py-6">
<form ref="formRef" @submit.prevent="onSubmit">
<InputGroup>
<InputGroupAddon v-if="files.length > 0" align="block-start" class="flex-wrap">
<Attachment v-for="file in files" :key="file.id" size="sm">
<AttachmentMedia>
<FileTextIcon />
</AttachmentMedia>
<AttachmentContent>
<AttachmentTitle>{{ file.name }}</AttachmentTitle>
</AttachmentContent>
<AttachmentActions>
<AttachmentAction
:aria-label="`Remove ${file.name}`"
@click="removeFile(file.id)"
>
<XIcon />
</AttachmentAction>
</AttachmentActions>
</Attachment>
</InputGroupAddon>
<InputGroupTextarea
v-model="text"
placeholder="Ask the agent to change your code..."
class="p-3"
@keydown="onKeydown"
/>
<InputGroupAddon align="block-end">
<InputGroupButton
size="icon-sm"
variant="outline"
class="rounded-full"
aria-label="Attach files"
@click="fileDialog.open()"
>
<PlusIcon />
</InputGroupButton>
<DropdownMenu>
<DropdownMenuTrigger as-child>
<InputGroupButton
size="sm"
variant="outline"
:aria-label="`Model: ${currentModel.name}`"
class="ml-auto"
>
{{ currentModel.name }}
<ChevronDownIcon />
</InputGroupButton>
</DropdownMenuTrigger>
<DropdownMenuContent align="start" class="w-48">
<DropdownMenuRadioGroup v-model="model">
<template v-for="(provider, index) in providers" :key="provider.name">
<DropdownMenuSeparator v-if="index > 0" />
<DropdownMenuGroup>
<DropdownMenuLabel>{{ provider.name }}</DropdownMenuLabel>
<DropdownMenuRadioItem
v-for="item in provider.models"
:key="item.id"
:value="item.id"
>
{{ item.name }}
</DropdownMenuRadioItem>
</DropdownMenuGroup>
</template>
</DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
<DropdownMenu>
<DropdownMenuTrigger as-child>
<InputGroupButton
size="sm"
variant="outline"
:aria-label="`Effort: ${currentEffort.name}`"
>
<span class="text-muted-foreground">Effort</span>
{{ currentEffort.name }}
<ChevronDownIcon />
</InputGroupButton>
</DropdownMenuTrigger>
<DropdownMenuContent align="start" class="w-36">
<DropdownMenuGroup>
<DropdownMenuLabel>Effort</DropdownMenuLabel>
<DropdownMenuRadioGroup v-model="effort">
<DropdownMenuRadioItem
v-for="item in efforts"
:key="item.id"
:value="item.id"
>
{{ item.name }}
</DropdownMenuRadioItem>
</DropdownMenuRadioGroup>
</DropdownMenuGroup>
</DropdownMenuContent>
</DropdownMenu>
<InputGroupButton
type="submit"
size="icon-sm"
variant="default"
class="rounded-full"
:disabled="!canSend"
aria-label="Send"
>
<ArrowUpIcon />
</InputGroupButton>
</InputGroupAddon>
</InputGroup>
</form>
</div>
</template>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.
pnpm dlx shadcn-vue@latest add input-group attachment dropdown-menu
Usage
<script setup lang="ts">
import { ArrowUpIcon, PlusIcon } from '@lucide/vue'
import { useFileDialog } from '@vueuse/core'
import { computed, ref } from 'vue'
import {
InputGroup,
InputGroupAddon,
InputGroupButton,
InputGroupTextarea,
} from '@/components/ui/input-group'
const text = ref('')
const formRef = ref<HTMLFormElement | null>(null)
const fileDialog = useFileDialog({ multiple: true, reset: true })
const canSend = computed(() => text.value.trim().length > 0)
</script>
<template>
<form ref="formRef" @submit.prevent="onSubmit">
<InputGroup>
<InputGroupTextarea
v-model="text"
placeholder="Ask the agent to change your code..."
class="p-3"
/>
<InputGroupAddon align="block-end">
<InputGroupButton
size="icon-sm"
variant="outline"
class="rounded-full"
aria-label="Attach files"
@click="fileDialog.open()"
>
<PlusIcon />
</InputGroupButton>
<InputGroupButton
type="submit"
size="icon-sm"
variant="default"
class="ml-auto rounded-full"
:disabled="!canSend"
aria-label="Send"
>
<ArrowUpIcon />
</InputGroupButton>
</InputGroupAddon>
</InputGroup>
</form>
</template>Attachments
The attach button opens a file dialog with useFileDialog. 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.
<script setup lang="ts">
function onKeydown(event: KeyboardEvent) {
if (event.key === 'Enter' && !event.shiftKey) {
event.preventDefault()
formRef.value?.requestSubmit()
}
}
</script>
<template>
<InputGroupTextarea v-model="text" @keydown="onKeydown" />
</template>AI SDK
Send the text and the FileList from the file dialog.
chat.sendMessage({ text, files })The route streams the reply with result.toUIMessageStreamResponse().
Migrating from AI Elements Vue
If you added Prompt Input from AI Elements Vue, your project has a components/ai-elements/prompt-input/ folder. 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.
Migrate components/ai-elements/prompt-input/ from AI Elements Vue to the shadcn-vue 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-vue@latest add input-group attachment
2. Read https://www.shadcn-vue.com/docs/ai-elements/prompt-input 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 class="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 files no longer use.
5. Run vue-tsc and fix any errors.Sponsors
Your logo hereshadcn-vue is free and open source. Sponsorship keeps it maintained.
Become a sponsor