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

ConversationList

Props, styling and a live ConversationList example.

View as Markdown
ConversationList
Sample data
@polymorfa/react

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.

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

  • controllerInboxControllerrequired

    Supplies rows, selection and loading.

  • onSelect(conversation: InboxConversation) => void

    Called when a row is selected.

  • classNamestring

    Root class and slot classes.

  • classNamesSlotClassNames

    Root class and slot classes.

  • actions(conversation: InboxConversation) => readonly InboxRowAction[]

    Only offer actions supported and authorized by the host.

  • titleReactNode

    List heading.

  • searchboolean

    Shows the search field.

    Default true

  • querystring

    Controlled search, when supplied.

  • onQueryChange(query: string) => void

    Controlled 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() => void

    Shows a New chat button.

Types#

Named types used in the props above.

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