mcpField
C
chat-ui

chat-ui

github.com/inference-sh设计与 UI7891.0k 次安装2 周前更新
代码仓库

关于 chat-ui

chat-ui 是用于构建对话界面的组件集,面向开发聊天应用的前端开发者。它提供消息容器、输入框和状态指示等构件,并采用 Tailwind CSS 与 shadcn/ui 设计令牌。

主要功能

  1. 01聊天容器与消息组件
  2. 02聊天输入组件
  3. 03输入状态指示器
  4. 04用户、助手和系统消息变体
  5. 05Tailwind CSS 与 shadcn/ui 样式

适用场景

  1. 01搭建聊天应用界面
  2. 02呈现用户与助手消息
  3. 03显示正在输入状态

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/inference-sh/skills --skill chat-ui

安装后在 Claude Code 中输入/chat-ui确认已加载。

详细介绍

安装 belt CLI 技能: npx skills add belt-sh/cli

聊天 UI 组件

来自 ui.inference.sh 的聊天构建模块。

聊天 UI 组件

快速入门

# Install chat components
npx shadcn@latest add https://ui.inference.sh/r/chat.json

组件

聊天容器
import { ChatContainer } from "@/registry/blocks/chat/chat-container"

<ChatContainer>
  {/* messages go here */}
</ChatContainer>
消息
import { ChatMessage } from "@/registry/blocks/chat/chat-message"

<ChatMessage
  role="user"
  content="Hello, how can you help me?"
/>

<ChatMessage
  role="assistant"
  content="I can help you with many things!"
/>
聊天输入框
import { ChatInput } from "@/registry/blocks/chat/chat-input"

<ChatInput
  onSubmit={(message) => handleSend(message)}
  placeholder="Type a message..."
  disabled={isLoading}
/>
正在输入指示器
import { TypingIndicator } from "@/registry/blocks/chat/typing-indicator"

{isTyping && <TypingIndicator />}

完整示例

import {
  ChatContainer,
  ChatMessage,
  ChatInput,
  TypingIndicator,
} from "@/registry/blocks/chat"

export function Chat() {
  const [messages, setMessages] = useState([])
  const [isLoading, setIsLoading] = useState(false)

  const handleSend = async (content: string) => {
    setMessages(prev => [...prev, { role: 'user', content }])
    setIsLoading(true)
    // Send to API...
    setIsLoading(false)
  }

  return (
    <ChatContainer>
      {messages.map((msg, i) => (
        <ChatMessage key={i} role={msg.role} content={msg.content} />
      ))}
      {isLoading && <TypingIndicator />}
      <ChatInput onSubmit={handleSend} disabled={isLoading} />
    </ChatContainer>
  )
}

消息变体

角色描述
user用户消息(右对齐)
assistantAI 响应(左对齐)
system系统消息(居中)

样式

组件使用 Tailwind CSS 和 shadcn/ui 设计令牌:

<ChatMessage
  role="assistant"
  content="Hello!"
  className="bg-muted"
/>

相关技能

# Full agent component (recommended)
npx skills add inference-sh/skills@agent-ui

# Declarative widgets
npx skills add inference-sh/skills@widgets-ui

# Markdown rendering
npx skills add inference-sh/skills@markdown-ui

文档

组件文档:ui.inference.sh/blocks/chat

评论

支持 Markdown