Chat | CoUI

Chat

통일된 채팅 메시지 행 / 말풍선 / 그룹 컴포넌트.

Chat#

Chat / ChatGroup / ChatBubble 은 Flutter / Web 양쪽에서 동일한 API 로 채팅 인터페이스를 구성합니다.

Live Preview#

Web
Support
Hello! How can I help?
10:00 AM
I have a question.
10:01 AM
Flutter
Loading Flutter...
class ChatDefaultExample extends StatelessComponent {
  const ChatDefaultExample({super.key});

  @override
  Component build(BuildContext context) {
    return div(
      const [
        Chat(
          header: Component.text('Support'),
          bubble: ChatBubble(
            child: Component.text('Hello! How can I help?'),
          ),
          footer: Component.text('10:00 AM'),
        ),
        Gap.space12(),
        Chat(
          alignment: CoreChatAlignment.end,
          bubble: ChatBubble(
            alignment: CoreChatAlignment.end,
            variant: CoreChatBubbleVariant.primary,
            child: Component.text('I have a question.'),
          ),
          footer: Component.text('10:01 AM'),
        ),
      ],
      classes: 'flex flex-col w-full',
    );
  }
}
class ChatDefaultExample extends StatelessWidget {
  const ChatDefaultExample({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisSize: MainAxisSize.min,
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: const [
        Chat(
          header: Text('Support'),
          bubble: ChatBubble(
            child: Text('Hello! How can I help?'),
          ),
          footer: Text('10:00 AM'),
        ),
        Gap.space12(),
        Chat(
          alignment: CoreChatAlignment.end,
          bubble: ChatBubble(
            alignment: CoreChatAlignment.end,
            variant: CoreChatBubbleVariant.primary,
            child: Text('I have a question.'),
          ),
          footer: Text('10:01 AM'),
        ),
      ],
    );
  }
}

컴포넌트 구성#

  • Chat — 한 번의 메시지 한 줄. 슬롯: avatar / header / bubble / footer.
  • ChatGroup — 같은 발신자의 메시지 묶음. 슬롯: avatar / header / bubbles[] / footer.
  • ChatBubble — 말풍선 컨테이너. 슬롯: child. variant (8 종) 와 tail boolean 으로 색상 / 꼬리 제어.

기본 사용법 (Basic Usage)#

Chat(
  header: Text('Support'),
  bubble: ChatBubble(child: Text('Hello! How can I help?')),
  footer: Text('10:00 AM'),
)

Chat(
  alignment: CoreChatAlignment.end,
  bubble: ChatBubble(
    alignment: CoreChatAlignment.end,
    variant: CoreChatBubbleVariant.primary,
    child: Text('I have a question.'),
  ),
  footer: Text('10:01 AM'),
)
Chat(
  header: Component.text('Support'),
  bubble: ChatBubble(
    child: Component.text('Hello! How can I help?'),
  ),
  footer: Component.text('10:00 AM'),
)

Chat(
  alignment: CoreChatAlignment.end,
  bubble: ChatBubble(
    alignment: CoreChatAlignment.end,
    variant: CoreChatBubbleVariant.primary,
    child: Component.text('I have a question.'),
  ),
  footer: Component.text('10:01 AM'),
)

Props#

Chat#

속성타입기본값설명
bubble Widget / Component 필수 메시지 본체 (보통 ChatBubble).
avatar Widget? / Component? null 행 옆에 표시되는 아바타.
header Widget? / Component? null 버블 위 헤더 (발신자명 등).
footer Widget? / Component? null 버블 아래 풋터 (타임스탬프).
alignment CoreChatAlignment start start / end.
chatStyle CoreChatStyle? null gap / header & footer 텍스트 스타일 override.

ChatBubble#

속성타입기본값설명
child Widget / Component 필수 메시지 내용.
variant CoreChatBubbleVariant neutral neutral / primary / secondary / accent / info / success / warning / error.
alignment CoreChatAlignment start tail 방향.
tail bool true 꼬리(speech-bubble pointer) 표시.
chatBubbleStyle CoreChatBubbleStyle? null padding / radius / 색상 / maxWidthFactor 등 override.

ChatGroup#

속성타입기본값설명
bubbles List<Widget> / List<Component> 필수 같은 발신자의 연속 메시지들.
avatar Widget? / Component? null 그룹에 한 번만 표시되는 아바타.
header Widget? / Component? null 그룹 헤더.
footer Widget? / Component? null 그룹 풋터.
alignment CoreChatAlignment start 그룹 정렬.
chatStyle CoreChatStyle? null gap / 텍스트 스타일 override.

디자인 토큰#

토큰기본값설명
CoreChatStyle.defaultAvatarSpacing CoreSpace.space8 (8px) 아바타-버블 간격.
CoreChatStyle.defaultGroupSpacing CoreSpace.space4 (4px) 그룹 내 버블 간격 (Column.spacing / flex gap).
CoreChatBubbleStyle.defaultPadding 8px / 12px 버블 내부 패딩.
CoreChatBubbleStyle.defaultBorderRadius CoreRadius.radius12 (12px) 버블 모서리.
CoreChatBubbleStyle.defaultMaxWidthFactor 0.75 사용 가능 너비의 75%.
CoreChatBubbleStyle.defaultTailWidth CoreSpace.space8 (8px) 꼬리 가로폭.
CoreChatBubbleStyle.defaultTailHeight6px꼬리 세로폭.
CoreChatBubbleStyle.defaultTailRadius CoreRadius.radius2 (2px) 꼬리 곡률.

관련 컴포넌트#

  • Avatar — 메시지 발신자 표시.
  • Loading — AI 응답 대기 인디케이터.
  • TextField — 입력 영역.