LobeChatLobeHub
UI
Components
Chat
Mobile
Awesome
Brand
Mdx
Icons
Color
Changelog
Ctrl
K
Data Display
ChatItem
ChatList
TokenTag
Data Entry
ChatInputArea
EditableMessage
EditableMessageList
MessageInput
Feedback
MessageModal
Layout
ChatHeader
Navigation
BackBottom

ChatList

ChatList is a flexible component for rendering chat conversations with rich customization options. It displays an array of ChatMessage objects with support for loading states, custom message rendering, action handling, and error management. The component supports 'bubble' and 'docs' variants, can display history dividers, and allows for role-specific customization of messages, items, and actions.

import { ChatList } from '@lobehub/ui/chat';
NPM
UNPKG
BundlePhobia
PackagePhobia
Anvaka Graph
Source
Edit
Previous
ChatItem
Next
TokenTag

Resources

Lobe UI-AIGC Components
Lobe Icon-AI / LLM Icon Collection
Lobe Charts-Modern Charts
Lobe TTS-TTS / STT Library

Community

Report Bug
Request Feature

Help

GitHub
Changelog

More Products

🤯 Lobe Chat-AI / LLM Chat Framework
🧸 Lobe Vidol-Virtual Idols for EveryOne
🅰️ Lobe Theme-Stable Diffusion Extension
🌐 Lobe i18n-AI i18next CLI
Copyright © 2022-2025
Made with 🤯 by LobeHub
LobeHub

Default

APIs

ChatList

PropertyDescriptionTypeDefault
dataArray of chat messages to display (required)ChatMessage[]-
enableHistoryCountWhether to show history message countbooleanfalse
historyCountNumber of messages to mark as historynumber-
loadingIdID of the message in loading statestring-
onActionsClickCallback when action buttons are clicked(action: ActionIconGroupEvent, message: ChatMessage) => void-
onAvatarsClickCallback for avatar clicks by role(role: RenderRole) => () => void-
onMessageChangeCallback when message content changes(id: string, content: string) => void-
renderActionsCustom renderers for action buttons by type{ [actionKey: string]: RenderAction }-
renderErrorMessagesCustom renderers for error messages by type{ [errorType: 'default' | string]: RenderErrorMessage }-
renderItemsCustom renderers for chat items by role{ [role: RenderRole]: RenderItem }-
renderMessagesCustom renderers for message content by role{ [role: RenderRole]: RenderMessage }-
renderMessagesExtraCustom renderers for additional message content by role{ [role: RenderRole]: RenderMessageExtra }-
showTitleWhether to display chat item titlesbooleanfalse
textCustomizable text strings{ copySuccess?: string; history?: string; copy?: string; delete?: string; edit?: string; regenerate?: string; [key: string]: string }-
variantVisual style of the chat list'docs' | 'bubble''bubble'
...DivPropsAll properties from div elementDivProps-

Types

typescript
type ChatMessage = {
  id: string;
  content: string;
  role: LLMRoleType | string;
  // Additional properties defined in the chat message type
};

type RenderRole = LLMRoleType | 'default' | string;
type RenderItem = FC<{ key: string } & ChatMessage & ListItemProps>;
type RenderMessage = FC<ChatMessage & { editableContent: ReactNode }>;
type RenderMessageExtra = FC<ChatMessage>;
type RenderAction = FC<ChatActionsBarProps & ChatMessage>;

interface RenderErrorMessage {
  Render?: FC<ChatMessage>;
  config?: AlertProps;
}
CanisMinor
2023-06-10 22:59:10

dayjs 如何使用 fromNow

😎
2023-06-12 03:02:30

要使用 dayjs 的 fromNow 函数,需要先安装 dayjs 库并在代码中引入它。然后,可以使用以下语法来获取当前时间与给定时间之间的相对时间:

javascript
dayjs().fromNow(); // 获取当前时间的相对时间
dayjs('2021-05-01').fromNow(); // 获取给定时间的相对时间

第一个示例将返回类似于 "几秒前"、"一分钟前"、"2 天前" 的相对时间字符串,表示当前时间与调用 fromNow 方法时的时间差。第二个示例将返回给定时间与当前时间的相对时间字符串。