Chat
A conversation's parts — MessageBubble (time, receipt, retry), TypingIndicator, MessageComposer, ConversationItem — the same API on the web and React Native.
- Domaine
- Conversation et IA
- Niveau de support
- Taille
- 6.2 kB gzip, budget 7.6 kB
- Qui l'utilise
- 4 fichiers des produits et sites en production l'importent (Sovkora : 1) Compté dans l'inventaire daté du 2026-11-23.
import { MessageBubble, TypingIndicator, MessageComposer, ConversationItem } from "@krizaka/ui/chat";Web et mobile — le même composant pour React et React Native. Bêta : son API peut encore changer à une version mineure.
Pourquoi il est là. Used by Sovkora, krizaka.com.
Quand l’utiliser
- A creator app's messages, a community's chats, support threads.
- An inbox of conversations with presence and unread counts.
Quand ne pas l’utiliser
Installation
Installer
npm install @krizaka/ui @krizaka/tailwind @krizaka/tokens tailwindcssStyles
@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";Importer
import { MessageBubble, TypingIndicator, MessageComposer, ConversationItem } from "@krizaka/ui/chat";Exemples
Conversation
Grouped runs, a read receipt, typing, the composer.
Inbox
Online, typing, unread counts.
Pill composer
One rounded field: chip and attach inside, round send inside, a status line under it.
Props
ConversationItem
A conversation in the list: avatar, name, the last message or typing, the time, the unread count.
| Prop | Type | Défaut | Description |
|---|---|---|---|
namerequis | string | — | The other person's name. |
previewrequis | string | — | The last message, or “typing…”. |
avatar | string | null | — | Their avatar's URL. |
className | string | — | Classes merged on the row. |
href | string | — | Opens the conversation (a link). |
online | boolean | — | Before the name: a presence dot (online). |
onlineLabel | string | — | The presence in words (“online”). |
onSelect | (() => void) | — | Opens the conversation (a button). |
time | string | — | When (“14:02”, “Mon”). |
typing | boolean | — | The preview is the typing signal: in the accent. |
unread | number | 0 | Unread messages: a count, the name in bold. |
unreadLabel | string | — | The unread count in words (“3 unread”). |
MessageBubble
A message: yours in the accent on the right, theirs on the left, the time inside, the receipt under the last of yours.
| Prop | Type | Défaut | Description |
|---|---|---|---|
textrequis | string | — | The text. |
className | string | — | Classes merged on the row. |
context | string | — | A line above the text: what it answers. |
grouped | "middle" | "single" | "first" | "last" | single | Part of a run of the same sender: the corner towards the next one is tighter. |
labels | MessageBubbleLabels | — | The words, passed translated. |
mine | boolean | — | Yours (right, in the accent) or theirs (left). |
onRetry | (() => void) | — | Sends a failed message again (a button under it). |
showStatus | boolean | — | Show the status under the bubble (the last message of yours). |
status | MessageStatus | — | Where a message of yours stands; shown when showStatus. |
time | string | — | The time, written by the app (“14:02”). |
MessageComposer
Where a message is written: a growing textarea (Enter sends, Shift+Enter a new line), an attach slot, a send button. The pill variant is the one-field look of the Krizaka chat card.
| Prop | Type | Défaut | Description |
|---|---|---|---|
onSendrequis | () => void | — | Sends the draft (Enter, or the button); Shift+Enter adds a line. |
onValueChangerequis | (text: string) => void | — | Called on every key. |
placeholderrequis | string | — | The input's name and placeholder (“Message”). |
sendLabelrequis | string | — | The send button's name (“Send”). |
valuerequis | string | — | The draft (controlled). |
busy | boolean | false | An answer is on its way: the send is held (and aria-busy is set) while the field stays where it is, size included. |
canSend | boolean | — | Overrides “the draft has text” — e.g. an attachment alone can be sent. A busy composer never sends. |
className | string | — | Classes merged on the root. |
disabledReason | string | — | Cannot write: the reason in its place. |
inputProps | Omit<Omit<DetailedHTMLProps<TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref">, "className" | ... 4 more ... | "rows"> | — | Attributes (data-testid, autoFocus, id…) forwarded to the textarea. |
leading | ReactNode | — | Before the input: an attach button (bar), or the mode/model chip and attach, inside the field (pill). |
maxLength | number | 4000 | The longest message. Default 4000. |
sendProps | Omit<Omit<DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "className" | ... 2 more ... | "type"> | — | Attributes forwarded to the send button. |
status | ReactNode | — | pill: the quiet line under the field (privacy, cost estimate). Its row is always reserved, so a changing line never moves the field. Read politely. |
variant | "pill" | "bar" | bar | bar: a docked bar with a square-ish field. pill: one rounded field holding leading, the text and a round send button — no inner border. Default bar. |
TypingIndicator
Three dots that breathe while the other person types, announced politely; still under reduced motion.
| Prop | Type | Défaut | Description |
|---|---|---|---|
labelrequis | string | — | What is read and shown beside the dots (“Elena is typing”) — passed translated. |
className | string | — | Classes merged on the root. |
showLabel | boolean | — | Show the words beside the dots. |
Accessibilité
- Each bubble is read with its time; a failed one says so and offers a retry.
- The
pillstatus line is a polite live region; a busy composer holds the send (aria-busy) and says nothing else. - The typing dots are announced politely by their words.
- A conversation row reads name, presence, last message, time and unread count.
Clavier
| Touches | Action |
|---|---|
| Enter / Shift+Enter | In the web composer: send, or a new line. |
Bonnes pratiques
- Group the runs of one sender (
grouped); show the receipt under the last message of yours only. - Keep the server's order and merge (the app's), the bubble only draws.
- The composer never clears itself: clear the draft once the message is sent.
variant="pill"for a chat page: put the mode/model chip and attach inleading, privacy and cost instatus, and passbusywhile an answer streams — the field's box does not move.
Composants liés
Générée depuis le code de @krizaka/ui 5.3.4 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub