You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Star1Β (1)You must be signed in to star a repository
About
Reusable, plug-and-play threaded comments and review trees for React. Features infinite nesting, pagination, role-based replies, emoji search, attachments, and plain JSON normalization.
Provider and model selectors are opt-in for ChatThread. On wide layouts, the settings panel sits beside the conversation. On narrow layouts, a compact model summary opens the same controls in a dialog. A host can preconfigure credentials and hide the key field while keeping both selectors visible:
To let demo users provide their own key, set showChatApiKeyInput to true and handle onChatApiKeyChange. Keys are not persisted or included in ThreadCraftSubmitPayload. The Vite demo sends chat requests to the selected provider from the browser; production apps can load models and submit messages through their own backend.
The native entry uses React Native components and does not require the CSS import. When attachments are enabled, pass onPickAttachments and connect it to the app's native file picker.
Integrations
Use case
Component
Data
GitHub issue
GitHubIssueThread
kind: "issue"; optional issue status, URL, author, and body
Product review
ReviewThread
kind: "review"; set showRating: true to display review stars; use allowRatingInput to control rating entry
AI chat
ChatThread
kind: "chat"; optionally enable provider/model controls with showChatProviderControls, chatProviders, and onLoadChatModels; onSubmitComment receives the selected provider and model
Dynamic variant
ThreadedDiscussion
Optional variant; defaults to data.kind, then "issue"
Component options
Prop
Type
Default
Description
data
ThreadCraftData
Required
Metadata and initial comments
variant
"issue" | "review" | "chat"
data.kind ?? "issue"
Used by ThreadedDiscussion; wrapper components select their own variant
currentUser
string
"You"
Author for locally created comments
showHeader
boolean
true
Show the issue, product, or chat header
initialRootLimit
number
50
Root comments shown first; their nested replies remain visible
loadMoreCount
number
initialRootLimit or 50
Root comments revealed or requested per βSee moreβ
allowReplies
boolean
true
Show reply actions
allowNewComments
boolean
true
Show the root-level composer
allowAttachments
boolean
true
Show attachments; native apps provide onPickAttachments
allowReactions
boolean
false for chat; true otherwise
Show reaction actions
showStreamHeading
boolean
true
Show the discussion, review, or message count heading
loadMorePlacement
"start" | "end"
"start" for chat, "end" otherwise
Place a loaded page before or after the current roots
loadMoreLabel
string
Variant-specific
Idle pagination button text
loadingMoreLabel
string
Variant-specific
Pagination loading text
loadMoreErrorText
string
Variant-specific
Error shown when a page request rejects
emptyMessage
string
Variant-specific
Text shown when the discussion has no comments
inputPlaceholder
string
Variant-specific
Composer placeholder
composerLabel
string
Variant-specific
Accessible composer label
submitButtonLabel
string
Variant-specific
Composer submit button text
submittingLabel
string
Variant-specific
Composer submit loading text
allowEmoji
boolean
false for chat; true otherwise
Show the emoji picker
typingIndicator
boolean
false
Show a chat assistant typing indicator
typingIndicatorLabel
string
"AI assistant is thinking"
Accessible typing indicator label
isSubmitting
boolean
false
Disable the composer while the host app processes a message
controlledComments
boolean
false
Sync parent-owned data.comments; recommended for AI chat
showChatProviderControls
boolean
false
Show provider/model settings beside wide chats and in a dialog on narrow chats
chatProviders
ThreadCraftChatProviderOption[]
[]
Provider labels, optional API keys, and preloaded models
showChatApiKeyInput
boolean
true
Show a password input while provider controls are enabled; set false when the host supplies credentials
selectedChatProvider
string
First provider
Controlled provider selection
selectedChatModel
string
First available model
Controlled model selection
onChatProviderChange
(provider: string) => void
β
Observe provider selection changes
onChatModelChange
(model: string) => void
β
Observe model selection changes
onChatApiKeyChange
(provider: string, apiKey: string) => void
β
Receive key input changes; the package does not persist keys
Custom chip, card, and avatar colors by authorType
showRating
boolean
Display rating stars on review comments
hasMore
boolean
Whether more root comments are available
totalRootComments
number
Total root count shown in the discussion heading
For chat, comments are displayed oldest to newest. Set hasMore when older messages are available. The chat pagination control appears at the top and expects onLoadMore to return older comments; controlledComments keeps the parent as the source of truth.
Comment: ThreadCraftComment
Field
Type
Meaning
id
string | number
Required comment identifier
author
string
Required author name
text
string
Preferred comment content
body
string
Content alias; text takes precedence
authorAvatarUrl
string
Author avatar URL
avatarBackgroundColor
string
Per-user initials avatar background override
avatarTextColor
string
Per-user initials avatar text override
avatarBorderColor
string
Per-user avatar border override
cardColor
string
Per-comment card background override
cardBorderColor
string
Per-comment card border override
cardTextColor
string
Per-comment card text override
createdAt
string
Comment timestamp; displayed inside chat bubbles in chat mode
parentId
string | number | null
Flat reply parent; null marks a root
quotedCommentId
string | number | null
Alternative flat reply parent
quotedText
string
Quoted parent text
quotedAuthor
string
Quoted parent author
replies
ThreadCraftComment[]
Nested replies; recursive
reactions
Record<string, number>
Emoji-to-count map, e.g. {"π": 2}
attachments
ThreadCraftAttachmentInput[]
Image URLs or attachment objects
rating
number
Review rating
ratings
number
Legacy rating alias; rating takes precedence
isCustomer
boolean
Legacy customer-author flag
isMine
boolean
Legacy flag treated as customer-authored
authorType
string
customer, business, support, bot, user, assistant, or custom role
Email input configuration and initial value; keyboardType is "default" or "email-address"
Author type style: ThreadCraftAuthorTypeStyle
Add styles to ThreadCraftData.authorTypeStyles, keyed by the comment's authorType. Styles apply to that role on every nesting level. Per-comment avatar and card colors override role defaults.
Color values accept CSS color formats such as hex, rgb(), hsl(), and named colors. authorAvatarUrl accepts an image URL or data URL and replaces the initials avatar.
Reusable, plug-and-play threaded comments and review trees for React. Features infinite nesting, pagination, role-based replies, emoji search, attachments, and plain JSON normalization.