Skip to content
Shortcut: /, ⌘K or Ctrl+K

MessageList

Props, styling and a live MessageList example.

View as Markdown
MessageList
Sample data
@polymorfa/react

Customize

Presentation-only: never reloads history or cancels a send.

Show a Reply action on each message.

MessageListExample.jsx
npm install @polymorfa/react@dev @polymorfa/browser@dev
import { 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#

  • classNamestring

    Class for the root.

  • classNamesSlotClassNames

    Classes keyed by slot.

  • controllerConversationController

    Conversation to render.

  • createController() => ConversationController

    Factory for a controller the component owns.

  • messageFilter(message: ConversationMessage) => boolean

    Presentation-only: never reloads history or cancels a send.

  • renderMessage(message: ConversationMessage) => ReactNode

    Replaces a bubble's content.

  • renderAttachmentRenderAttachment

    Replaces one attachment.

  • onReply(message: ConversationMessage) => void

    Show a Reply action on each message.

Types#

Named types used in the props above.

@polymorfa/react
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.