Chat Elements
Preview

UI-only chat building blocks for composing AI interfaces without Cubitt owning your runtime data.

Overview

Chat Elements are smaller composable pieces for AI chat interfaces. They are visual components only: consumers own messages, transport, persistence, tool state, and stream orchestration.

Use them when you want Cubitt styling and composition pieces without adopting a larger chat runtime contract.

Open full chat example

Usage

import {
  Conversation,
  Message,
  PromptInput,
} from "@tilt-legal/cubitt-components/chat-elements";

Setup

MessageResponse uses Streamdown for markdown rendering. Consumer apps need streamdown installed and should include Streamdown in Tailwind's source scan, with the path adjusted for their app:

@source "../node_modules/streamdown/dist/*.js";

PromptInput owns its own transient composer state. No Chat Elements provider needs to be installed globally.

Components

Boundary

These components intentionally do not prescribe a message schema beyond small UI-facing prop types. Use your own chat hooks, AI SDK transport, backend routes, and persistence model, then pass the relevant values into the visual elements.

API Reference

Shared Types

These UI-facing types are exported from @tilt-legal/cubitt-components/chat-elements and are shared across the chat element pages.

UIMessage

Minimal message shape used by message, conversation, and prompt examples.

FieldTypeDescription
idstringUnique message id.
role"system" | "user" | "assistant"Message role.
metadataunknownOptional consumer-owned metadata.
partsunknown[]Consumer-owned message parts.

FileUIPart

File part shape used when prompt attachments are submitted to consumers.

FieldTypeDescription
type"file"File part discriminator.
mediaTypestringFile MIME type.
filenamestringOptional filename.
urlstringFile URL or data URL.
providerMetadataunknownOptional provider-specific metadata.
namestringOptional display name inherited from file UI data.
sizenumberOptional file size in bytes.
sizeLabelstringOptional formatted size label.
descriptionstringOptional display description.
badgeReact.ReactNodeOptional display badge.
iconReact.ReactNodeOptional display icon.
thumbnailUrlstringOptional thumbnail URL.
state"default" | "loading" | "uploading" | "error"Optional display state.
progressnumberOptional upload/loading progress.
disabledbooleanOptional disabled state.
sourceunknownOptional consumer source payload.

ChatFileUIPart is an alias of FileUIPart.

ChatAttachmentFile

Attachment file shape used by prompt and message attachment UI.

FieldTypeDescription
idstringUnique attachment id.
file fieldsFileUIPart fieldsFile display and URL data.

ChatAttachmentFileData is the same shape with id optional, for attachment display cases where the consumer does not need a stable id.

SourceDocumentUIPart

Source-document shape accepted by attachment and referenced-source APIs.

FieldTypeDescription
type"source-document"Source document discriminator.
mediaTypestringOptional MIME type.
titlestringOptional source title.
filenamestringOptional source filename.
urlstringOptional source URL.
providerMetadataunknownOptional provider-specific metadata.

ChatStatus

Runtime status values accepted by prompt controls.

ValueDescription
"processing"The runtime has accepted the prompt and is preparing a response.
"streaming"The runtime is streaming a response.

On this page