The ChatPromptSubmit component is used inside the ChatPrompt component to submit the prompt. It automatically handles the different status values to control the chat.
It extends the Button component, so you can pass any property such as color, variant, size, etc.
You can also use it inside the footer slot of the ChatPrompt component.
When its status is ready, use the color, variant and icon props to customize the Button. Defaults to:
color="primary"variant="solid"icon="i-lucide-arrow-up"<template>
<UChatPromptSubmit color="primary" variant="solid" icon="i-lucide-arrow-up" />
</template>
You can customize this icon globally in your app.config.ts under ui.icons.arrowUp key.
You can customize this icon globally in your vite.config.ts under ui.icons.arrowUp key.
When its status is submitted, use the submitted-color, submitted-variant and submitted-icon props to customize the Button. Defaults to:
submittedColor="neutral"submittedVariant="subtle"submittedIcon="i-lucide-square"The stop event is emitted when the user clicks on the Button.
<template>
<UChatPromptSubmit
submitted-color="neutral"
submitted-variant="subtle"
submitted-icon="i-lucide-square"
status="submitted"
/>
</template>
You can customize this icon globally in your app.config.ts under ui.icons.stop key.
You can customize this icon globally in your vite.config.ts under ui.icons.stop key.
When its status is streaming, use the streaming-color, streaming-variant and streaming-icon props to customize the Button. Defaults to:
streamingColor="neutral"streamingVariant="subtle"streamingIcon="i-lucide-square"The stop event is emitted when the user clicks on the Button.
<template>
<UChatPromptSubmit
streaming-color="neutral"
streaming-variant="subtle"
streaming-icon="i-lucide-square"
status="streaming"
/>
</template>
You can customize this icon globally in your app.config.ts under ui.icons.stop key.
You can customize this icon globally in your vite.config.ts under ui.icons.stop key.
When its status is error, use the error-color, error-variant and error-icon props to customize the Button. Defaults to:
errorColor="error"errorVariant="soft"errorIcon="i-lucide-rotate-ccw"The reload event is emitted when the user clicks on the Button.
<template>
<UChatPromptSubmit
error-color="error"
error-variant="soft"
error-icon="i-lucide-rotate-ccw"
status="error"
/>
</template>
You can customize this icon globally in your app.config.ts under ui.icons.reload key.
You can customize this icon globally in your vite.config.ts under ui.icons.reload key.
These chat components are designed to be used with the AI SDK v5 from Vercel AI SDK.
Check out the source code of our AI Chat template on GitHub for a real-life example.
Use the ChatPromptSubmit component with the Chat class from AI SDK v5 to display a chat prompt within a page.
Pass the status prop and listen to the stop and reload events to control the chat.
<script setup lang="ts">
import { Chat } from '@ai-sdk/vue'
import { getTextFromMessage } from '@nuxt/ui/utils/ai'
const input = ref('')
const chat = new Chat({
onError(error) {
console.error(error)
}
})
function onSubmit() {
chat.sendMessage({ text: input.value })
input.value = ''
}
</script>
<template>
<UDashboardPanel>
<template #body>
<UContainer>
<UChatMessages :messages="chat.messages" :status="chat.status">
<template #content="{ message }">
<MDC :value="getTextFromMessage(message)" :cache-key="message.id" class="*:first:mt-0 *:last:mb-0" />
</template>
</UChatMessages>
</UContainer>
</template>
<template #footer>
<UContainer class="pb-4 sm:pb-6">
<UChatPrompt v-model="input" :error="chat.error" @submit="onSubmit">
<UChatPromptSubmit :status="chat.status" @stop="chat.stop" @reload="chat.regenerate" />
</UChatPrompt>
</UContainer>
</template>
</UDashboardPanel>
</template>
| Prop | Default | Type |
|---|---|---|
status |
|
|
icon |
|
The icon displayed in the button when the status is |
color |
| The color of the button when the status is |
variant |
| The variant of the button when the status is |
streamingIcon |
The icon displayed in the button when the status is | |
streamingColor | The color of the button when the status is | |
streamingVariant | The variant of the button when the status is | |
submittedIcon |
|
The icon displayed in the button when the status is |
submittedColor |
| The color of the button when the status is |
submittedVariant |
| The variant of the button when the status is |
errorIcon |
|
The icon displayed in the button when the status is |
errorColor |
|
The color of the button when the status is |
errorVariant |
|
The variant of the button when the status is |
label |
| |
size |
|
|
ui |
|
| Slot | Type |
|---|---|
leading |
|
default |
|
trailing |
|
| Event | Type |
|---|---|
stop | |
reload |
|
export default defineAppConfig({
ui: {
chatPromptSubmit: {
slots: {
base: ''
}
}
}
})
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
ui: {
chatPromptSubmit: {
slots: {
base: ''
}
}
}
})
]
})