Conversation
会話の流れ。自分の話は右、相手の返事は左に、時の順に並べる。新しい話は下に足す。続けて同じ人が話した時は、名前と頭像を省いて間を詰める。書く欄は持たないので、下に TextField や Textarea を置く。
tsx
import { Conversation } from "knowidea-ui";カテゴリ: Data display。同じカテゴリ: Avatar、Badge、Chip、Status、Stat、Table、List、Timeline、Tooltip、Popover、CodeBlock、Kbd、Quote、Display、Jacket、CodeEditor、DiffView
Demos
デモの数値はすべてサンプルであり、実際の値ではない。
Basic
相手の話には名前と頭像が付く。時刻は <time> で出す。
- 色の検査の結果を教えて。
- 作本文と背景の差は、どのページも 4.5:1 以上でした。
- 線の差が足りない所が 2 か所あり、直しています。
- 直ったら知らせて。
Show code
tsx
import { Conversation, type ConversationMessage } from "knowidea-ui";const messages: ConversationMessage[] = [ { id: "1", from: "self", author: "自分", time: "2026-10-13T09:20", timeLabel: "09:20", body: "色の検査の結果を教えて。" }, { id: "2", from: "other", author: "作る役", time: "2026-10-13T09:21", timeLabel: "09:21", body: "本文と背景の差は、どのページも 4.5:1 以上でした。" }, { id: "3", from: "other", author: "作る役", time: "2026-10-13T09:21", timeLabel: "09:21", body: "線の差が足りない所が 2 か所あり、直しています。" }, { id: "4", from: "self", author: "自分", time: "2026-10-13T09:24", timeLabel: "09:24", body: "直ったら知らせて。" },];function Basic() { return <div style={{ width: "100%" }}><Conversation messages={messages} /></div>;}Pending reply
相手が返事を書いている間は、pending の 1 行を出す。点を動かす飾りは使わない。
- 色の検査の結果を教えて。
- 作本文と背景の差は、どのページも 4.5:1 以上でした。
- 線の差が足りない所が 2 か所あり、直しています。
- 直ったら知らせて。
作る役が返事を書いている
Show code
tsx
import { Conversation, type ConversationMessage } from "knowidea-ui";const messages: ConversationMessage[] = [ { id: "1", from: "self", author: "自分", time: "2026-10-13T09:20", timeLabel: "09:20", body: "色の検査の結果を教えて。" }, { id: "2", from: "other", author: "作る役", time: "2026-10-13T09:21", timeLabel: "09:21", body: "本文と背景の差は、どのページも 4.5:1 以上でした。" }, { id: "3", from: "other", author: "作る役", time: "2026-10-13T09:21", timeLabel: "09:21", body: "線の差が足りない所が 2 か所あり、直しています。" }, { id: "4", from: "self", author: "自分", time: "2026-10-13T09:24", timeLabel: "09:24", body: "直ったら知らせて。" },];function Pending() { return <div style={{ width: "100%" }}><Conversation messages={messages} pending="作る役が返事を書いている" /></div>;}Sending and failed
送っている途中の話は薄く、送れなかった話は枠の色と文字で示す。
- 予定を 1 日延ばして。
- 理由も書いておいて。
Show code
tsx
import { Conversation } from "knowidea-ui";function Status() { return ( <div style={{ width: "100%" }}> <Conversation messages={[ { id: "1", from: "self", author: "自分", timeLabel: "09:30", time: "2026-10-13T09:30", body: "予定を 1 日延ばして。", status: "sending" }, { id: "2", from: "self", author: "自分", timeLabel: "09:31", time: "2026-10-13T09:31", body: "理由も書いておいて。", status: "failed" }, ]} /> </div> );}States
すべてのコンポーネントが、Empty、Loading、Error、Disabled、Focus の 5 つの状態を備える。Hover と Active は、確認用に固定して表示している。そのコンポーネントにあてはまらない状態は「対象外」とし、理由を添える。
| State | Appearance |
|---|---|
| Empty | まだ話が無い 下の欄から話しかけると、ここに並ぶ。 話が 0 件の時は empty を出す |
| Loading | Skeleton で吹き出しの形をまねる。相手が書いている間は pending の 1 行を出し、動かさない |
| Error |
送れなかった話は枠の色と「送れなかった」の文字で示す。送り直す操作は使う側が置く |
| Disabled | 対象外。無効状態を持たない。押せる所を持たない |
| Focus | 対象外。押せる所を持たない。吹き出しの中のリンクは、ふつうのリンクとして focus を受ける |
API
| Name | Type | Default | Description |
|---|---|---|---|
messages | ConversationMessage[] | - | { id, from: "self" | "other", author, avatar?, time?, timeLabel?, body, status? } |
pending | string | - | 相手が返事を書いている時の 1 行 |
empty | ReactNode | - | 話が 1 つも無い時に出す物 |
label | string | "会話" | 読み上げの名前 |
CSS
Classes and data attributes
| Name | Description |
|---|---|
.ki-convo | 本体。role="log" |
.ki-convo__msg | 話。data-from: self | other、data-continued、data-status: sending | failed |
.ki-convo__bubble、__author、__meta、__status、__pending | 内部の要素 |
CSS variables
コンポーネントが参照するのは、役割を表す名前の変数だけで、素の値は参照しない。オーバーライドの方法は Overriding を参照。
| Variable | Usage |
|---|---|
| --color-surface-2 | 相手の吹き出しの面 |
| --color-primary | 自分の吹き出しの面(12% を混ぜる) |
| --color-error | 送れなかった話の枠 |
Accessibility
- role="log" なので、足された話は読み上げが順に伝える
- 自分の話の名前は見た目には出さず、読み上げにだけ出す
- 送れなかった事は色だけでなく「送れなかった」の文字で伝える