Skip to content
Hazine

Centered Chat Thread

One reading-width column with a scrolling message stream and a composer pinned under it. Use it for a focused one-to-one assistant conversation that needs no history or side panel.

How it differs. One column and nothing else: title bar, stream, composer. Following the reply pauses when the reader scrolls up and resumes through a jump button that floats over the stream.

Install

pnpm dlx shadcn@latest add @hazine/chat-thread-centered

Adds 2 files, 3 shadcn primitives (avatar, button, textarea), 3 Hazine items (@hazine/copy-button, @hazine/heading, @hazine/use-controllable-state), and 1 package (lucide-react).

First time? Add the registry to components.json
{
  "registries": {
    "@hazine": "https://api.hazine.dev/r/{name}.json"
  }
}

Needed once per project. Items resolve each other through the @hazine namespace.

Props16

messages
ChatMessage[]
defaultMessages
ChatMessage[] = DEFAULT_MESSAGES
onMessagesChange
(messages: ChatMessage[]) => void
onMessageSend
(message: ChatMessage) => void
Called with the user turn that was just appended. Start the request here.
status
ChatStatus = "ready"
error
string = "The reply did not arrive. Check your connection, then retry."
Shown when status is "error". Say what happened and what to do next.
onReplyStop
() => void
Called by the Stop button while a reply is pending or streaming. The button is disabled without it.
onReplyRetry
() => void
Called by the retry button in the error state. The button is hidden without it.
title
string = "Porto offsite budget"
headingLevel
HeadingLevel = 2
assistantName
string = "Marlow"
suggestions
string[] = DEFAULT_SUGGESTIONS
Starter prompts for the empty state. Choosing one fills the message field and does not send.
defaultDraft
string = ""
maxLength
number = 2000
Longest message in characters. A counter appears from 80 percent of it.
locale
string = "en-US"
timeZone
string = "UTC"
IANA time zone for message times. Fixed by default so server and client render the same text.

Also accepts every prop of Omit<React.ComponentProps<"section">, "title">.

Accessibility

Pattern
Landmarks and headings, Form with labelled fields, Button (APG, opens in a new tab)
Keyboard
Keyboard support for Centered Chat Thread
KeyEffect
TabMoves to the message stream, then the copy button of each reply, retry when a reply failed, the jump button when it is shown, the message field and Send or Stop
Arrow Up, Arrow Down, Page Up, Page Down, Home, End on the streamScrolls the messages. Scrolling up pauses following and shows the jump button
Enter or Space on the jump buttonScrolls to the newest message, resumes following and moves focus to the message field
Enter in the message fieldSends the message and keeps focus in the field. Does nothing while a reply is pending, and keeps focus on the field when the message is over the limit
Shift+Enter in the message fieldStarts a new line
Enter or Space on StopStops the pending reply. Focus moves to the message field when Send is disabled afterwards
Enter or Space on Retry replyRequests the reply again and moves focus to the message field
Enter or Space on a starter promptFills the message field with the prompt without sending and moves focus to the field
Screen reader

Section labelled by its heading. Messages are articles named by author and time inside a polite log that a reply joins once it is complete, the composer is a named form with a labelled field, and progress, errors and the length limit are announced.

  • Announces: Loading conversation.
  • Announces: {assistant} is thinking.
  • Announces: {assistant} is writing.
  • Announces: Prompt added to the message field. Edit it, then send.
  • Announces: Reply copied
  • Announces: {error}
Reduced motion
The spinner and the loading skeleton stay still. Scrolling to the latest message is always instant.
Checked
Not checked yet. Automated results appear here once CI has run.

Dependencies7

  • avatar
  • button
  • textarea
  • @hazine/copy-button
  • @hazine/heading
  • @hazine/use-controllable-state
  • lucide-react

Filled chips are registry items the CLI adds for you. Outlined chips are npm packages.

Tokens shipped0

None. The item is styled by the tokens your theme already has.