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

Inbox

Props, styling and a live Inbox example.

View as Markdown
Inbox
Sample data
@polymorfa/react

Customize

Where conversations come from. Defaults to your handler's history and events routes, through the provider's client.

Supply your own controller to drive the inbox from outside.

Open this conversation first.

Show the contact panel toggle. Defaults to `true`.

Extra content inside the contact panel.

Actions in the thread header. Defaults to a `<CallButton/>` when the grant allows `voip_place` and the conversation has a phone number.

composerProps17 props

Offer file attachments: the attach button, drop and paste. Defaults to `true`. Turn it off when the composer's actions have no upload adapter.

File types the attach button offers, as for `<input accept>`.

Offer named file types. Omit to keep the single file picker.

Allow picking several files at once. Defaults to `true`.

Resolves the reply banner's quoted message without a controller.

Replaces the locale's `composer.placeholder`.

Rendered in the toolbar before the built-in buttons.

Rendered after the message field, before the send or mic button.

Show the emoji picker button. Defaults to `true`.

Show the voice note button. Defaults to `true` where the browser has `MediaRecorder` and `getUserMedia`.

Send a voice note as soon as it finishes uploading. Defaults to `true`.

Options for the "/" quick reply menu.

Called after a quick reply's text is inserted.

Rows the message field grows to before it scrolls. Defaults to 8.

InboxExample.jsx
npm install @polymorfa/react@dev @polymorfa/browser@dev
import { PolymorfaProvider, Inbox } from "@polymorfa/react";

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

export function InboxExample() {
  return (
    <PolymorfaProvider tokenEndpoint="/api/polymorfa/token" appearance={appearance}>
      <style>{"/* Composer row alignment until the UI Kit stylesheet includes it. */\n.pmfa-composer .pmfa-input { min-height: 40px; padding-block: max(4px, calc((40px - 1.45em - 2px) / 2)); }\n.pmfa-chat-window .pmfa-composer .pmfa-input { min-height: 44px; padding-block: max(4px, calc((44px - 1.4em - 2px) / 2)); }\n.pmfa-chat-window .pmfa-composer-row .pmfa-btn-icon { min-height: 44px; margin-block: 0; }\n@media (max-width: 600px) { .pmfa-composer .pmfa-input { min-height: 44px; padding-block: max(4px, calc((44px - 1.45em - 2px) / 2)); } }"}</style>
      <Inbox
        defaultConversationId="avery"
        contactPanel
        title="Support"
        composerProps={{
          emoji: true,
          attachments: false,
          voiceNotes: false,
          placeholder: "Write a message…"
        }}
      />
    </PolymorfaProvider>
  );
}

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

For custom attachment uploads, compose the inbox from individual components.

Props#

  • sourceInboxDataSource

    Where conversations come from. Defaults to your handler's history and events routes, through the provider's client.

    Default Your route's history and events routes

  • controllerInboxController

    Supply your own controller to drive the inbox from outside.

  • defaultConversationIdstring

    Open this conversation first.

  • onSelect(conversation: InboxConversation | undefined) => void

    Called when the open conversation changes.

  • contactPanelboolean

    Show the contact panel toggle. Defaults to true.

    Default true

  • renderContact(conversation: InboxConversation) => ReactNode

    Extra content inside the contact panel.

  • renderActions(conversation: InboxConversation) => ReactNode

    Actions in the thread header. Defaults to a <CallButton/> when the grant allows voip_place and the conversation has a phone number.

    Default A call button

  • titleReactNode

    List heading.

    Default Locale text

  • composerPropsOmit<ComposeBoxProps, "controller" | "createController" | "conversation">

    Props for the composer. See ComposeBox.

  • classNamestring

    Class for the root.

  • classNamesSlotClassNames

    Classes keyed by slot.

composerProps#

  • onSent() => void

    Called after a send.

  • classNamestring

    Class for the root.

  • classNamesSlotClassNames

    Classes keyed by slot.

  • attachmentsboolean

    Offer file attachments: the attach button, drop and paste. Defaults to true. Turn it off when the composer's actions have no upload adapter.

    Default true

  • acceptstring

    File types the attach button offers, as for <input accept>.

  • attachmentKindsreadonly AttachmentKind[]

    Offer named file types. Omit to keep the single file picker.

  • multipleboolean

    Allow picking several files at once. Defaults to true.

    Default true

  • messagesreadonly ConversationMessage[]

    Resolves the reply banner's quoted message without a controller.

  • placeholderstring

    Replaces the locale's composer.placeholder.

    Default Locale text

  • startActionsReactNode

    Rendered in the toolbar before the built-in buttons.

  • endActionsReactNode

    Rendered after the message field, before the send or mic button.

  • emojiboolean

    Show the emoji picker button. Defaults to true.

    Default true

  • voiceNotesboolean

    Show the voice note button. Defaults to true where the browser has MediaRecorder and getUserMedia.

    Default true where supported

  • voiceNoteAutoSendboolean

    Send a voice note as soon as it finishes uploading. Defaults to true.

    Default true

  • quickRepliesreadonly QuickReplyOption[]

    Options for the "/" quick reply menu.

  • onQuickReply(option: QuickReplyOption) => void

    Called after a quick reply's text is inserted.

  • maxRowsnumber

    Rows the message field grows to before it scrolls. Defaults to 8.

    Default 8

Types#

Named types used in the props above.

@polymorfa/ui
type AttachmentKind =
  | "image"
  | "video"
  | "audio"
  | "document";

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.