MessageList
Props, styling and a live MessageList example.
Customize
Presentation-only: never reloads history or cancels a send.
Show a Reply action on each message.
npm install @polymorfa/react@dev @polymorfa/browser@devimport { PolymorfaProvider, MessageList } from "@polymorfa/react";
const appearance = { theme: "light", variables: { colorPrimary: "#635bff" } };
export function MessageListExample({ conversation }) {
return (
<PolymorfaProvider tokenEndpoint="/api/polymorfa/token" appearance={appearance}>
<MessageList
controller={conversation}
/>
</PolymorfaProvider>
);
}MessageList from @polymorfa/react. Choose props and styles above; the preview stays visible in every code view.
Props#
classNamestringClass for the root.
classNamesSlotClassNamesClasses keyed by slot.
controllerConversationControllerConversation to render.
createController() => ConversationControllerFactory for a controller the component owns.
messageFilter(message: ConversationMessage) => booleanPresentation-only: never reloads history or cancels a send.
renderMessage(message: ConversationMessage) => ReactNodeReplaces a bubble's content.
renderAttachmentRenderAttachmentReplaces one attachment.
onReply(message: ConversationMessage) => voidShow a Reply action on each message.
Types#
Named types used in the props above.
type RenderAttachment = (attachment: MessageAttachment, message: ConversationMessage) => ReactNode;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.