chatpromptsoumission

Un bouton pour soumettre des invites de chat avec gestion automatique du statut.

Utilisation

Le composant ChatPromptSubmit est utilisé à l'intérieur du composant ChatPrompt pour soumettre l'invite. Il gère automatiquement les différentes valeurs status pour contrôler le chat.

Il étend le composant Button, de sorte que vous pouvez passer n'importe quelle propriété telle que color, variant, size, etc.

<template>
  <UChatPrompt>
    <UChatPromptSubmit />
  </UChatPrompt>
</template>
Vous pouvez également l'utiliser dans l'emplacement footer du composant ChatPrompt.

prêt

Lorsque son statut est ready, utilisez les accessoires color, variant et icon pour personnaliser le bouton.

  • xxcolor="primary"xx{lang="ts-type"}
  • xvariant="solid"xx{lang="ts-type"}
  • xicon="i-lucide-arrow-up"x{lang="ts-type"}
<template>
  <UChatPromptSubmit color="primary" variant="solid" icon="i-lucide-arrow-up" />
</template>
Vous pouvez personnaliser cette icône globalement dans votre app.config.ts sous la touche ui.icons.arrowUp.
Vous pouvez personnaliser cette icône globalement dans votre vite.config.ts sous la touche ui.icons.arrowUp.

Répondre

Lorsque son statut est submitted, utilisez les accessoires submitted-color, submitted-variant et submitted-icon pour personnaliser le bouton.

  • xsubmittedColor="neutral"xx{lang="ts-type"}
  • xxsubmittedVariant="subtle"xxxph0777x
  • xxsubmittedIcon="i-lucide-square"xx{lang="ts-type"}
L'événement stop est émis lorsque l'utilisateur clique sur le bouton.
<template>
  <UChatPromptSubmit
    submitted-color="neutral"
    submitted-variant="subtle"
    submitted-icon="i-lucide-square"
    status="submitted"
  />
</template>
Vous pouvez personnaliser cette icône globalement dans votre app.config.ts sous la touche ui.icons.stop.
Vous pouvez personnaliser cette icône globalement dans votre vite.config.ts sous la touche ui.icons.stop.

Streaming

Lorsque son statut est streaming, utilisez les accessoires streaming-color, streaming-variant et streaming-icon pour personnaliser le bouton.

  • xstreamingColor="neutral"x{lang="ts-type"}
  • xstreamingVariant="subtle"
  • xstreamingIcon="i-lucide-square"x{lang="ts-type"}
L'événement stop est émis lorsque l'utilisateur clique sur le bouton.
<template>
  <UChatPromptSubmit
    streaming-color="neutral"
    streaming-variant="subtle"
    streaming-icon="i-lucide-square"
    status="streaming"
  />
</template>
Vous pouvez personnaliser cette icône globalement dans votre app.config.ts sous la touche ui.icons.stop.
Vous pouvez personnaliser cette icône globalement dans votre vite.config.ts sous la touche ui.icons.stop.

erreur

Lorsque son statut est error, utilisez les accessoires error-color, error-variant et error-icon pour personnaliser le bouton.

  • errorColor="error"x{lang="ts-type"}
  • xerrorVariant="soft"x{lang="ts-type"}
  • xerrorIcon="i-lucide-rotate-ccw"x{lang="ts-type"}
L'événement reload est émis lorsque l'utilisateur clique sur le bouton.
<template>
  <UChatPromptSubmit
    error-color="error"
    error-variant="soft"
    error-icon="i-lucide-rotate-ccw"
    status="error"
  />
</template>
Vous pouvez personnaliser cette icône globalement dans votre app.config.ts sous la touche ui.icons.reload.
Vous pouvez personnaliser cette icône globalement dans votre vite.config.ts sous la touche ui.icons.reload.

Exemples

Consultez la page d'aperçu Chat pour les instructions d'installation, la configuration du serveur et les exemples d'utilisation.

API

Props

Prop Default Type
as
'button'
any

The element or component this component should render as when not a link.

status
'ready'
"error" | "ready" | "submitted" | "streaming"
icon
appConfig.ui.icons.arrowUp
any

The icon displayed in the button when the status is ready. Set to false to hide the icon.

color
'primary'
"error" | "primary" | "secondary" | "success" | "info" | "warning" | "neutral"

The color of the button when the status is ready.

variant
'solid'
"link" | "outline" | "soft" | "subtle" | "ghost" | "solid"

The variant of the button when the status is ready.

streamingIcon
appConfig.ui.icons.stop
any

The icon displayed in the button when the status is streaming.

streamingColor
'neutral'
"error" | "primary" | "secondary" | "success" | "info" | "warning" | "neutral"

The color of the button when the status is streaming.

streamingVariant
'subtle'
"link" | "outline" | "soft" | "subtle" | "ghost" | "solid"

The variant of the button when the status is streaming.

submittedIcon
appConfig.ui.icons.stop
any

The icon displayed in the button when the status is submitted.

submittedColor
'neutral'
"error" | "primary" | "secondary" | "success" | "info" | "warning" | "neutral"

The color of the button when the status is submitted.

submittedVariant
'subtle'
"link" | "outline" | "soft" | "subtle" | "ghost" | "solid"

The variant of the button when the status is submitted.

errorIcon
appConfig.ui.icons.reload
any

The icon displayed in the button when the status is error.

errorColor
'error'
"error" | "primary" | "secondary" | "success" | "info" | "warning" | "neutral"

The color of the button when the status is error.

errorVariant
'soft'
"link" | "outline" | "soft" | "subtle" | "ghost" | "solid"

The variant of the button when the status is error.

autofocus
false | true | "true" | "false"
avatar
AvatarProps

Display an avatar on the left side.

loading
boolean

When true, the loading icon will be displayed.

loadingIcon
appConfig.ui.icons.loading
any

The icon when the loading prop is true.

disabled
boolean
name
string
label
string
size
'md'
"xs" | "sm" | "md" | "lg" | "xl"
leading
boolean

When true, the icon will be displayed on the left side.

leadingIcon
any

Display an icon on the left side.

trailing
boolean

When true, the icon will be displayed on the right side.

trailingIcon
any

Display an icon on the right side.

type
'button'
"reset" | "submit" | "button"

The type of the button when not a link.

activeColor
"error" | "primary" | "secondary" | "success" | "info" | "warning" | "neutral"
activeVariant
"link" | "outline" | "soft" | "subtle" | "ghost" | "solid"
square
boolean

Render the button with equal padding on all sides.

block
boolean

Render the button full width.

loadingAuto
boolean

Set loading state automatically based on the @click promise state

ui
{ base?: SlotClass; } & { base?: SlotClass; label?: SlotClass; leadingIcon?: SlotClass; leadingAvatar?: SlotClass; leadingAvatarSize?: SlotClass; trailingIcon?: SlotClass; }
Ce composant prend également en charge tous les attributs HTML natifs <button>.

Slots

Slot Type
leading
{ ui: object; }
default
{ ui: object; }
trailing
{ ui: object; }

Emits

Event Type
stop
[event: MouseEvent]
reload
[event: MouseEvent]

Thème

app.config.ts
export default defineAppConfig({
  ui: {
    chatPromptSubmit: {
      slots: {
        base: ''
      }
    }
  }
})
vite.config.ts
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: ''
          }
        }
      }
    })
  ]
})

Changelog

No recent changes