ChatPromptSubmit
ChatPromptSubmit (채팅 프롬프트 제출)
ChatPromptSubmit 컴포넌트는 채팅 프롬프트를 제출하기 위한 Button으로, 상태를 자동으로 처리해 줘요. 채팅을 제어하는 여러 status 값을 자동으로 다루면서 프롬프트를 전송하는 버튼이에요.
출처: Nuxt UI
본문
사용법 (Usage)
ChatPromptSubmit 컴포넌트는 ChatPrompt 컴포넌트 안에서 프롬프트를 제출할 때 사용해요. 채팅을 제어하는 다양한 status 값을 자동으로 처리해요.
Button 컴포넌트를 확장하므로 color, variant, size 등 어떤 속성이든 전달할 수 있어요.
<template>
<UChatPrompt>
<UChatPromptSubmit />
</UChatPrompt>
</template>
[!NOTE]
ChatPrompt컴포넌트의footer슬롯 안에서도 사용할 수 있어요.
준비 상태 (Ready)
status가 ready일 때 color, variant, icon prop으로 Button을 커스터마이즈할 수 있어요. 기본값은 다음과 같아요:
color="primary"variant="solid"icon="i-lucide-arrow-up"
<template>
<UChatPromptSubmit color="primary" variant="solid" icon="i-lucide-arrow-up" />
</template>
Nuxt:
[!TIP] See: /docs/getting-started/integrations/icons/nuxt#theme
이 아이콘은
app.config.ts의ui.icons.arrowUp키에서 전역으로 커스터마이즈할 수 있어요.
Vue:
[!TIP] See: /docs/getting-started/integrations/icons/vue#theme
이 아이콘은
vite.config.ts의ui.icons.arrowUp키에서 전역으로 커스터마이즈할 수 있어요.
제출 상태 (Submitted)
status가 submitted일 때 submitted-color, submitted-variant, submitted-icon prop으로 Button을 커스터마이즈할 수 있어요. 기본값은 다음과 같아요:
submittedColor="neutral"submittedVariant="subtle"submittedIcon="i-lucide-square"
[!NOTE]
사용자가 Button을 클릭하면
stop이벤트가 발생해요.
<template>
<UChatPromptSubmit submitted-color="neutral" submitted-variant="subtle" submitted-icon="i-lucide-square" status="submitted" />
</template>
Nuxt:
[!TIP] See: /docs/getting-started/integrations/icons/nuxt#theme
이 아이콘은
app.config.ts의ui.icons.stop키에서 전역으로 커스터마이즈할 수 있어요.
Vue:
[!TIP] See: /docs/getting-started/integrations/icons/vue#theme
이 아이콘은
vite.config.ts의ui.icons.stop키에서 전역으로 커스터마이즈할 수 있어요.
스트리밍 상태 (Streaming)
status가 streaming일 때 streaming-color, streaming-variant, streaming-icon prop으로 Button을 커스터마이즈할 수 있어요. 기본값은 다음과 같아요:
streamingColor="neutral"streamingVariant="subtle"streamingIcon="i-lucide-square"
[!NOTE]
사용자가 Button을 클릭하면
stop이벤트가 발생해요.
<template>
<UChatPromptSubmit streaming-color="neutral" streaming-variant="subtle" streaming-icon="i-lucide-square" status="streaming" />
</template>
Nuxt:
[!TIP] See: /docs/getting-started/integrations/icons/nuxt#theme
이 아이콘은
app.config.ts의ui.icons.stop키에서 전역으로 커스터마이즈할 수 있어요.
Vue:
[!TIP] See: /docs/getting-started/integrations/icons/vue#theme
이 아이콘은
vite.config.ts의ui.icons.stop키에서 전역으로 커스터마이즈할 수 있어요.
오류 상태 (Error)
status가 error일 때 error-color, error-variant, error-icon prop으로 Button을 커스터마이즈할 수 있어요. 기본값은 다음과 같아요:
errorColor="error"errorVariant="soft"errorIcon="i-lucide-rotate-ccw"
[!NOTE]
사용자가 Button을 클릭하면
reload이벤트가 발생해요.
<template>
<UChatPromptSubmit error-color="error" error-variant="soft" error-icon="i-lucide-rotate-ccw" status="error" />
</template>
Nuxt:
[!TIP] See: /docs/getting-started/integrations/icons/nuxt#theme
이 아이콘은
app.config.ts의ui.icons.reload키에서 전역으로 커스터마이즈할 수 있어요.
Vue:
[!TIP] See: /docs/getting-started/integrations/icons/vue#theme
이 아이콘은
vite.config.ts의ui.icons.reload키에서 전역으로 커스터마이즈할 수 있어요.
예제 (Examples)
[!TIP] See: /docs/components/chat
설치 방법, 서버 설정, 사용 예제는 Chat 개요 페이지를 확인하세요.
API
Props (속성)
/**
* Props for the ChatPromptSubmit component
*/
interface ChatPromptSubmitProps {
/**
* @default 'ready'
*/
status?: "error" | "ready" | "submitted" | "streaming" | undefined;
/**
* The icon displayed in the button when the status is `ready`. Set to `false` to hide the icon.
* @default appConfig.ui.icons.arrowUp
*/
icon?: any;
/**
* The color of the button when the status is `ready`.
* @default 'primary'
*/
color?: "error" | "primary" | "secondary" | "success" | "info" | "warning" | "neutral" | undefined;
/**
* The variant of the button when the status is `ready`.
* @default 'solid'
*/
variant?: "outline" | "soft" | "subtle" | "ghost" | "link" | "solid" | undefined;
/**
* The icon displayed in the button when the status is `streaming`.
* @default appConfig.ui.icons.stop
*/
streamingIcon?: any;
/**
* The color of the button when the status is `streaming`.
* @default 'neutral'
*/
streamingColor?: "error" | "primary" | "secondary" | "success" | "info" | "warning" | "neutral" | undefined;
/**
* The variant of the button when the status is `streaming`.
* @default 'subtle'
*/
streamingVariant?: "outline" | "soft" | "subtle" | "ghost" | "link" | "solid" | undefined;
/**
* The icon displayed in the button when the status is `submitted`.
* @default appConfig.ui.icons.stop
*/
submittedIcon?: any;
/**
* The color of the button when the status is `submitted`.
* @default 'neutral'
*/
submittedColor?: "error" | "primary" | "secondary" | "success" | "info" | "warning" | "neutral" | undefined;
/**
* The variant of the button when the status is `submitted`.
* @default 'subtle'
*/
submittedVariant?: "outline" | "soft" | "subtle" | "ghost" | "link" | "solid" | undefined;
/**
* The icon displayed in the button when the status is `error`.
* @default appConfig.ui.icons.reload
*/
errorIcon?: any;
/**
* The color of the button when the status is `error`.
* @default 'error'
*/
errorColor?: "error" | "primary" | "secondary" | "success" | "info" | "warning" | "neutral" | undefined;
/**
* The variant of the button when the status is `error`.
* @default 'soft'
*/
errorVariant?: "outline" | "soft" | "subtle" | "ghost" | "link" | "solid" | undefined;
ui?: { base?: SlotClass; } & { base?: SlotClass; label?: SlotClass; leadingIcon?: SlotClass; leadingAvatar?: SlotClass; leadingAvatarSize?: SlotClass; trailingIcon?: SlotClass; } | undefined;
autofocus?: false | true | "true" | "false" | undefined;
/**
* Display an avatar on the left side.
*/
avatar?: AvatarProps | undefined;
/**
* When `true`, the loading icon will be displayed.
*/
loading?: boolean | undefined;
/**
* The icon when the `loading` prop is `true`.
* @default appConfig.ui.icons.loading
*/
loadingIcon?: any;
disabled?: boolean | undefined;
form?: string | undefined;
name?: string | undefined;
onClick?: (event: MouseEvent): void | ((event: MouseEvent) => void)[] | undefined;
/**
* The element or component this component should render as when not a link.
* @default 'button'
*/
as?: any;
/**
* When `true`, the icon will be displayed on the right side.
*/
trailing?: boolean | undefined;
/**
* @default 'md'
*/
size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
/**
* When `true`, the icon will be displayed on the left side.
*/
leading?: boolean | undefined;
/**
* Display an icon on the left side.
*/
leadingIcon?: any;
/**
* Display an icon on the right side.
*/
trailingIcon?: any;
label?: string | undefined;
/**
* The type of the button when not a link.
* @default 'button'
*/
type?: "reset" | "submit" | "button" | undefined;
/**
* Class to apply when the link is exact active
*/
exactActiveClass?: string | undefined;
/**
* Pass the returned promise of `router.push()` to `document.startViewTransition()` if supported.
*/
viewTransition?: boolean | undefined;
formaction?: string | undefined;
formenctype?: string | undefined;
formmethod?: string | undefined;
formnovalidate?: false | true | "true" | "false" | undefined;
formtarget?: string | undefined;
activeColor?: "error" | "primary" | "secondary" | "success" | "info" | "warning" | "neutral" | undefined;
activeVariant?: "outline" | "soft" | "subtle" | "ghost" | "link" | "solid" | undefined;
/**
* Render the button with equal padding on all sides.
*/
square?: boolean | undefined;
/**
* Render the button full width.
*/
block?: boolean | undefined;
/**
* Set loading state automatically based on the `@click` promise state
*/
loadingAuto?: boolean | undefined;
}
[!NOTE] See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attributes
이 컴포넌트는 모든 네이티브
<button>HTML 속성도 지원해요.
Slots (슬롯)
/**
* Slots for the ChatPromptSubmit component
*/
interface ChatPromptSubmitSlots {
leading(): any;
default(): any;
trailing(): any;
}
Emits (이벤트)
/**
* Emitted events for the ChatPromptSubmit component
*/
interface ChatPromptSubmitEmits {
stop: (payload: [event: MouseEvent]) => void;
reload: (payload: [event: MouseEvent]) => void;
}
테마 (Theme)
export default defineAppConfig({
ui: {
chatPromptSubmit: {
slots: {
base: ''
}
}
}
})