ConversationList
Props, styling and a live ConversationList example.
Customize
Only offer actions supported and authorized by the host.
Controlled search, when supplied.
Confirm the mutation through the owning source, then refresh its rows.
React only: @polymorfa/elements has no element for ConversationList.
npm install @polymorfa/react@dev @polymorfa/browser@devimport { PolymorfaProvider, ConversationList } from "@polymorfa/react";
const appearance = { theme: "light", variables: { colorPrimary: "#635bff" } };
export function ConversationListExample({ inbox }) {
return (
<PolymorfaProvider tokenEndpoint="/api/polymorfa/token" appearance={appearance}>
<ConversationList
controller={inbox}
title="Conversations"
search
drafts={{ sam: "Your order is ready." }}
/>
</PolymorfaProvider>
);
}ConversationList from @polymorfa/react. Choose props and styles above; the preview stays visible in every code view.
Props#
controllerInboxControllerrequiredSupplies rows, selection and loading.
onSelect(conversation: InboxConversation) => voidCalled when a row is selected.
classNamestringRoot class and slot classes.
classNamesSlotClassNamesRoot class and slot classes.
actions(conversation: InboxConversation) => readonly InboxRowAction[]Only offer actions supported and authorized by the host.
titleReactNodeList heading.
searchbooleanShows the search field.
Default
truequerystringControlled search, when supplied.
onQueryChange(query: string) => voidControlled search.
draftsReadonly<Record<string, string>>Saved drafts by conversation ID, shown on rows and in the Drafts filter.
onAction(conversation: InboxConversation, action: InboxRowAction) => Promise<void>Confirm the mutation through the owning source, then refresh its rows.
onNewConversation() => voidShows a New chat button.
Types#
Named types used in the props above.
type InboxRowAction =
| "pin"
| "unpin"
| "archive"
| "unarchive"
| "mark-read"
| "mark-unread";Styling#
Use className, classNames (a class for any slot, typed SlotClassNames), appearance variables and element styles. The Style panel applies changes to the live component. See Appearance.
Setup#
Use the provider and server route for your application. The preview above uses local sample data and controllers. Chat controllers and inbox data sources keep your data separate from the UI.