Vize

Chat

Headless Chat; covers shadcn/ui, Vercel AI SDK chat, Adobe Spectrum.

Package @vizejs/ui/chat
Maturity stable
Quality gates behavior contract, mounted dom, type inference, tree shaking, bundle size, ssr, hydration, dom compile, ssr compile, vapor compile
Bundle budget 6,000 B JS gzip / 0 B CSS gzip
Own the source vize lib pull chat
Requires —
Aliases message log, conversation, ai chat, thread
Covers shadcn/ui, Vercel AI SDK chat, Adobe Spectrum

Minimal setup

Use a Vue 3.5+ project with Vue SFC compilation configured (see Vite+ integration).

vp install @vizejs/ui

Add the public import below to <script setup lang="ts">. Components provide behavior without styles; the preview uses optional Paper styles.

import { Chat, ChatMessage, ChatComposer } from "@vizejs/ui/chat";

Or copy the source into your project with vize lib pull chat (see Source Distribution).

Try it

This is the basic example maintained with the component source, using the public package imports. The preview adds the optional Paper styles.

Open the interactive example · Styling these components

Copy the example

<!-- Support thread with one message and a composer. -->
<script setup lang="ts">
import { ref } from "vue";

import { Chat, ChatComposer, ChatMessage } from "@vizejs/ui/chat";

const messages = ref([{ author: "Ada", text: "The build is green." }]);

function reply(text: string): void {
  messages.value = [...messages.value, { author: "You", text }];
}
</script>

<template>
  <Chat label="Support">
    <ChatMessage v-for="message in messages" :key="message.text" :author="message.author">
      {{ message.text }}
    </ChatMessage>
    <ChatComposer @send="reply" />
  </Chat>
</template>

A log, a message, and a composer

Chat is role="log" with polite live updates. ChatMessage is an article named by its author. ChatComposer trims the draft, ignores an empty send, and treats Enter as send. Shift+Enter stays a newline.

<script setup lang="ts">
import { Chat, ChatComposer, ChatMessage } from "@vizejs/ui/chat";
</script>

<template>
  <Chat label="Support">
    <ChatMessage author="Ada">The build is green.</ChatMessage>
    <ChatComposer @send="reply" />
  </Chat>
</template>

The composer does not call a model. The application owns the thread and appends the send payload.

API

Chat

Source: src/components/chat/chat.vue

Props

Prop Type Default Description
label string "Conversation" Accessible name of the log.

Slots

Slot Slot props Description
default — Renders messages and one composer.

ChatMessage

Source: src/components/chat/chat-message.vue

Props

Prop Type Default Description
author (required) string — Name announced for this message.

Slots

Slot Slot props Description
default — Renders the message body.

ChatComposer

Source: src/components/chat/chat-composer.vue

Props

Prop Type Default Description
label string "Message" Accessible name of the text field.
submitLabel string "Send" Label of the submit button.
disabled boolean false Disable the field and the button.

Events

Event Payload Description
send [text: string] Fired when the user sends a non-empty message. Carries the trimmed text. Enter sends. Shift+Enter inserts a newline.

Behavior

Normative state × input → outcome table for src/components/chat/chat.vue, src/components/chat/chat-message.vue, and src/components/chat/chat-composer.vue. Every row is proven by src/components/chat/tests/behavior.test.ts.

# State Input Outcome Proven by
H1 log with a message render role="log"; the message is an article named by its author renders a log of authored messages
H2 empty composer render the send button is disabled sends trimmed text and clears the draft
H3 draft hi Enter one send with hi; the field is cleared sends trimmed text and clears the draft
H4 draft with text Shift+Enter no send keeps Shift+Enter as a newline
H5 disabled composer Enter no send a disabled composer does not send