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

ConversationListView

Props, styling and a live ConversationListView example.

View as Markdown
ConversationListView
Sample data
@polymorfa/react

Customize

Controlled search, when supplied.

Confirm the mutation through the owning source, then refresh its rows.

Only offer actions supported and authorized by the host.

React only: @polymorfa/elements has no element for ConversationListView.

ConversationListViewExample.jsx
npm install @polymorfa/react@dev @polymorfa/browser@dev
import { useState } from "react";
import { PolymorfaProvider, ConversationListView } from "@polymorfa/react";

const appearance = { theme: "light", variables: { colorPrimary: "#635bff" } };

export function ConversationListViewExample({ conversation, conversations }) {
  const [selectedId, setSelectedId] = useState("avery");
  return (
    <PolymorfaProvider tokenEndpoint="/api/polymorfa/token" appearance={appearance}>
      <ConversationListView
        conversations={conversations}
        selectedId={selectedId}
        title="Conversations"
        search
        drafts={{ sam: "Your order is ready." }}
        status="ready"
        hasMore={false}
        onSelect={(conversation) => setSelectedId(conversation.id)}
      />
    </PolymorfaProvider>
  );
}

ConversationListView from @polymorfa/react. Choose props and styles above; the preview stays visible in every code view.

Props#

  • conversationsreadonly InboxConversation[]required

    Rows to show.

  • selectedIdstring

    The open conversation.

  • onSelect(conversation: InboxConversation) => voidrequired

    Called when a row is selected.

  • titleReactNode

    Same as ConversationList.

  • searchboolean

    Same as ConversationList.

  • querystring

    Controlled search, when supplied.

  • onQueryChange(query: string) => void

    Same as ConversationList.

  • draftsReadonly<Record<string, string>>

    Same as ConversationList.

  • onAction(conversation: InboxConversation, action: InboxRowAction) => Promise<void>

    Confirm the mutation through the owning source, then refresh its rows.

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

    Only offer actions supported and authorized by the host.

  • onNewConversation() => void

    Same as ConversationList.

  • statusInboxSnapshot["status"]

    Shows loading and error states.

  • onRetry() => void

    Retry action for the error state.

  • hasMoreboolean

    Shows Load more conversations.

    Default false

  • onLoadMore() => void

    Shows Load more conversations.

  • classNamestring

    Same as ConversationList.

  • classNamesSlotClassNames

    Same as ConversationList.

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.