Contents

Components

Chat

The room's text chat. A log that keeps up without dragging you along, messages that always say who wrote them, and nothing that renders as markup.

A live transcript

Maya Chen

Popcorn is ready. Somebody press play.

Leo joined,

Leo

Pressing play is a big responsibility.

Leo: I accept it anyway.

The host loaded a new video,

you

Subtitles on, please. The accents in this one are thick.

Sam can't play this video,

Maya Chen

Next week, this one: https://example.com/watch/the-extremely-long-director's-cut-with-the-commentary-track-and-the-deleted-scenes-nobody-asked-for

Scroll up first, then send: the log stays where you are and offers New messages.
import * as Chat from "@sideby/ui/chat";

<Chat.Log class="h-72">
  {#each rows as row, index (row.id)}
    {#if row.kind === "system"}
      <Chat.SystemLine text={row.text} time={row.time} tone={row.tone} />
    {:else}
      <Chat.Message
        author={row.author}
        text={row.text}
        time={row.time}
        datetime={row.datetime}
        self={row.authorId === me.id}
        grouped={isFollowUp(rows, index)}
      />
    {/if}
  {/each}
</Chat.Log>
<Chat.Composer onsend={(text) => room.sendChat(text)} maxlength={500} />

When to use it

Chat is the room’s side channel: reactions, “wait, go back”, plans for next week. It is text only. The parts are separate so a room screen can lay them out however it needs:

  • Chat.Log is the scrolling transcript.
  • Chat.Message is one member’s message.
  • Chat.SystemLine is the room speaking: who joined, what the host loaded, who can’t play.
  • Chat.Composer is the message field and its send button.

Rows go straight inside the log, one direct child per row, usually from an {#each} over the room’s messages.

Messages

ChatMessage

Maya Chen

Whoever paused it during the twist owes the room a snack.

Props
import * as Chat from "@sideby/ui/chat";

<Chat.Message author="Maya Chen" text="Whoever paused it during the twist owes the room a snack." time="21:04" datetime="2026-11-16T21:04" />

A message is a transcript row, not a bubble: the author’s avatar, their name in the label voice, the time in mono, then the text. Your own messages read you in the accent text, which is the only accent in a transcript. A follow-up from the same author is grouped: it drops the avatar and header so a run of quick lines reads as one thought.

The text keeps its line breaks, and a long unbroken string such as a pasted link wraps inside the column instead of pushing the page sideways.

System lines

ChatSystemLine

The host loaded a new video,

Props
tone
import * as Chat from "@sideby/ui/chat";

<Chat.SystemLine text="The host loaded a new video" time="21:03" />

A system line is the room itself talking, so it looks nothing like a member: no avatar, no author, just the words in the label voice between two hairlines. Most events are quiet. Use destructive only for a real failure, such as a member who can’t play the video, and let the words say what went wrong.

Member text can never take this shape. Only Chat.Message renders what members write, and it always sits under the author’s name, so nobody can type a line that passes for the room.

Composer

ChatComposer

Nothing sent yet.

Props
import * as Chat from "@sideby/ui/chat";

<Chat.Composer onsend={(text) => room.sendChat(text)} maxlength={500} />

The composer is a Textarea that starts one line tall and grows as you type, plus the send button. The send button is chat’s primary action, so it is the accent fill. It stays disabled until there is something to send: a draft of only spaces or blank lines never goes out, and what does go out is trimmed. After a send the field clears and keeps focus, so the next message can follow straight away.

Set maxlength to the room’s message limit. onsend receives the trimmed text; adding it to the log is the room’s job.

Empty

Nobody has said anything

No messages yet. Somebody has to go first.

import * as Chat from "@sideby/ui/chat";

<Chat.Log class="h-48" isEmpty={messages.length === 0}>
  {#each messages as message (message.id)}
    <Chat.Message {...message} />
  {/each}
</Chat.Log>

An empty log says so in one line, “No messages yet. Somebody has to go first.” Pass emptyText only when a product screen needs a different line.

Joining late

Joining late

Nothing here until you join. Press Join late and the whole backlog lands at once.

Press Join late: the log should open on the newest line, not the oldest.
import * as Chat from "@sideby/ui/chat";

<!-- A member who joins late receives the room's recent rows in one go.
     history marks the rows that came with the join: they are shown, not read aloud. -->
<Chat.Log class="h-48" isEmpty={rows.length === 0}>
  {#each rows as row (row.id)}
    {#if row.kind === "system"}
      <Chat.SystemLine text={row.text} time={row.time} history={row.history} />
    {:else}
      <Chat.Message author={row.author} text={row.text} time={row.time} history={row.history} />
    {/if}
  {/each}
</Chat.Log>

A member who joins mid-film gets the room’s recent history in one go. The log opens on the newest message, as if they had been there all along, and stays pinned there while the rows settle. A reader who has scrolled up is never moved by other people’s messages; sending your own always brings it into view.

Pass history on every row that came with the join rather than live. The log shows those rows but does not read them aloud: while they land it stops announcing, and it goes back to polite half a second after the last of them. The pause covers the whole log, so a live message that lands inside that half second is shown but not read aloud either. History rows never raise New messages. Only the room knows which rows came with the join, so the room sets history; never work it out from what a message says.

Accessibility

  • The log is role="log", named Chat by default (label changes it). New messages are announced politely, without interrupting. History that arrives as you join is not read aloud, and neither is a live message that lands within half a second of that history. Everything after that is announced.
  • The log takes keyboard focus, so arrow keys, Page Up and Page Down scroll it.
  • It stays at the newest message while you are at the bottom, including when the room’s history arrives all at once as you join. If you have scrolled up to read, other people’s messages never pull you down: a New messages button appears instead, and pressing it jumps down and moves focus to the log. Your own message always scrolls into view.
  • Every message is announced with its author. A grouped message hides the header visually but keeps the author’s name for screen readers, so no line is ever read without who said it.
  • The avatar in a message is hidden from screen readers, because the header already names the author.
  • A system line has no author, so it is read as just what happened, with its time.
  • The composer field is named Message and the button Send message. The text is 16px, so phones never zoom into the field.

Keyboard

  • Enter sends the message.
  • Shift+Enter adds a new line.
  • Typing with an input method (Japanese, Chinese, Korean and others) is safe: the Enter that confirms a composition picks the characters and never sends half a message.
  • Tab moves from the log to the field to the send button. On a phone keyboard the Enter key reads “send”.

Security

Every string a message shows, the author, the time and the text, renders as text. None of it is ever parsed as markup. From Phase 2 on, these strings come from other people in the room, so a message that contains angle brackets or a script tag shows exactly those characters and does nothing else.

Copy

Built-in words are plain: the log is Chat, your own author name is you, the jump button is New messages, the field is Message with the placeholder Say something, and the button is Send message. System lines are product copy: short, past tense, no exclamation marks (“Leo joined”, “The host loaded a new video”). The default empty line is the one piece of voice in the component. Message text is whatever members write.