Skip to content

Chat ​

Use @zeus-web/chat to build headless ChatGPT-style chat interfaces with Web Components and thin React/Vue wrappers.

@zeus-web/chatAdvancedGenerated

Playground ​

Source ​

Choose the framework entry that matches your application.

html
<script type="module">
  import '@zeus-web/chat/wc/auto'
</script>

<zw-chat>
  <zw-chat-thread slot="thread">
    <zw-chat-message role="assistant"> How can I help? </zw-chat-message>
  </zw-chat-thread>
  <zw-chat-composer slot="composer"></zw-chat-composer>
</zw-chat>
tsx
import {
  Chat,
  ChatComposer,
  ChatMessage,
  ChatThread,
} from '@zeus-web/chat/react'

export function SupportChat() {
  return (
    <Chat
      thread={
        <ChatThread>
          <ChatMessage role="assistant">How can I help?</ChatMessage>
        </ChatThread>
      }
      composer={<ChatComposer />}
    />
  )
}
vue
<script setup lang="ts">
import { Chat, ChatComposer, ChatMessage, ChatThread } from '@zeus-web/chat/vue'
</script>

<template>
  <Chat>
    <template #thread>
      <ChatThread>
        <ChatMessage role="assistant">How can I help?</ChatMessage>
      </ChatThread>
    </template>
    <template #composer>
      <ChatComposer />
    </template>
  </Chat>
</template>

When to use ​

  • Build AI chat, agent console or conversational assistant UIs.
  • Reuse the same chat behavior protocol across native Web Component, React and Vue.
  • Keep product styling free while reusing structure, events, methods and accessibility semantics.

When not to use ​

  • Do not treat it as a model request library.
  • Do not embed provider request logic inside the components.
  • Do not put credentials, secrets or tokens in component props.
  • Do not depend on Markdown parsing, syntax highlighting or file-upload transport in this phase.

Install ​

bash
pnpm add @zeus-web/chat

Component family ​

  • zw-chat
  • zw-chat-thread
  • zw-chat-message
  • zw-chat-composer
  • zw-chat-code-block
  • zw-chat-tool-call
  • zw-chat-artifact
  • zw-chat-typing

Slots ​

zw-chat ​

  • header
  • sidebar
  • thread
  • artifact
  • composer
  • empty
  • loadingContent

zw-chat-message ​

  • avatar
  • header
  • default
  • footer
  • actions

zw-chat-composer ​

  • prefix
  • attachments
  • submit
  • suffix

zw-chat-code-block ​

  • filenameContent
  • languageContent
  • actions
  • default

zw-chat-tool-call ​

  • summary
  • input
  • output
  • error
  • actions

zw-chat-artifact ​

  • header
  • default
  • footer
  • actions

Events ​

zw-chat ​

  • send
  • abort
  • regenerate
  • message-action
  • artifact-open

zw-chat-composer ​

  • send
  • value-change
  • attachment-change

zw-chat-message ​

  • message-action

zw-chat-code-block ​

  • code-action

zw-chat-artifact ​

  • artifact-open

Methods ​

zw-chat ​

  • setMessages
  • appendMessage
  • updateMessage
  • appendMessagePart
  • clear
  • getMessages
  • scrollToBottom
  • emitSend
  • emitAbort
  • emitRegenerate
  • emitMessageAction
  • emitArtifactOpen

zw-chat-thread ​

  • scrollToBottom

zw-chat-composer ​

  • focus
  • clear
  • submit

zw-chat-message ​

  • emitAction

zw-chat-code-block ​

  • emitAction

zw-chat-artifact ​

  • openArtifact

Examples ​

Native Web Component usage ​

Use the auto entry and compose chat, thread, message and composer with plain DOM.

ts
import '@zeus-web/chat/wc/auto'

const chat = document.createElement('zw-chat')
const thread = document.createElement('zw-chat-thread')
const composer = document.createElement('zw-chat-composer')

thread.slot = 'thread'
composer.slot = 'composer'

composer.addEventListener('send', event => {
  console.log((event as CustomEvent).detail.value)
})

chat.append(thread, composer)
document.body.append(chat)

React wrapper usage ​

Use the generated React wrapper when the host application is React.

tsx
import { Chat, ChatComposer, ChatThread } from '@zeus-web/chat/react'

export function App() {
  return (
    <Chat emptyText="No messages">
      <ChatThread slot="thread" />
      <ChatComposer slot="composer" placeholder="Type a message..." />
    </Chat>
  )
}

AI usage hints ​

  • Compose zw-chat, zw-chat-thread, zw-chat-message and zw-chat-composer when generating a chat interface.
  • Use zw-chat-code-block for code; do not put a syntax-highlighting library in the chat root.
  • Use the matching zw-chat-artifact slot for an artifact or canvas area.
  • Use zw-chat-tool-call to display tool calls.
  • Keep business request logic in the application layer.

Released under the MIT License.