Developers
Start building
Themes/Chat widget chrome

Chat widget chrome

Own the Inbox launcher and panel from src/layout/chat.tsx using the platform parts in @poltura/theme-sdk/inbox.

On this page

The storefront's Inbox chat widget is theme chrome, like the promo bar. The platform keeps the session, the live connection, message delivery and attachments behind @poltura/theme-sdk/inbox. The theme decides how the pieces are arranged.

Where it is

Put the widget in src/layout/chat.tsx as the file's default export. The storefront mounts it from that path. Without the file, the platform's complete widget mounts instead, the same one <InboxWidget /> draws. The default theme ships this file:

src/layout/chat.tsx
import {
  InboxChatGlyph,
  InboxComposer,
  InboxConversation,
  InboxLauncher,
  InboxOfflineForm,
  InboxPanel,
  InboxPanelHeader,
  InboxRoot,
  InboxStatusLine,
} from '@poltura/theme-sdk/inbox';

export default function ThemeChatWidget() {
  return (
    <InboxRoot className='pol-chat'>
      <InboxPanel className='pol-chat__panel'>
        <InboxPanelHeader className='pol-chat__header' />
        <InboxConversation className='pol-chat__conversation' />
        <InboxStatusLine className='pol-chat__status' />
        <InboxOfflineForm className='pol-chat__offline' />
        <InboxComposer className='pol-chat__composer' />
      </InboxPanel>
      <InboxLauncher className='pol-chat__launcher'>
        <InboxChatGlyph />
      </InboxLauncher>
    </InboxRoot>
  );
}

Every part must render inside <InboxRoot>, which renders nothing when the store offers no chat. useInbox() reads the view and actions from that context.

Render InboxConversation as the panel body. It shows the message list, and shows the open help article in its place once a shopper picks one. A layout that renders InboxMessageList directly must switch to InboxKnowledgeArticle itself while view.knowledge.article is set, or picking an article does nothing visible.

Parts

ComponentPropsRole
InboxRootchildren, className?Fixed wrapper, CSS variables, state and context
InboxWidgetnoneThe complete widget, built from the parts below
InboxLauncherclassName?, children?Button; children replace the default glyph
InboxPanelclassName?, childrenDialog (id="poltura-inbox-panel")
InboxPanelHeaderclassName?, title?, children?Accent header: title, reply-time / offline status, close icon
InboxConversationclassName?, renderMessage?Panel body: InboxMessageList, or the open article in its place
InboxMessageListclassName?, renderMessage?Scroll log, empty-state greeting and help, typing, jump to latest
InboxMessageBubblemessage, className?Default bubble
InboxComposerclassName?, placeholder?Pill with attach, text field and send icon
InboxOfflineFormclassName?Email and message fields when view.online === false
InboxStatusLineclassName?Reconnecting / preview bar above the composer
InboxChatGlyphsize?, className?Default launcher icon
InboxKnowledgeSearchclassName?, placeholder?Debounced help-article search (store knowledge base)
InboxKnowledgeArticleclassName?Open article body with back
InboxKnowledgeSuggestionsclassName?, limit?Top articles above the greeting when the thread is empty

useInbox() returns { view, actions }:

  • view.copy holds the widget's wording, already resolved: the theme's chat texts first, then the platform's inbox.* messages.
  • actions.send, attach, removeAttachment and retry are the only chat actions a theme calls. actions.open, close and toggle drive the panel.
  • view.appearance carries the merchant's side, colour mode and colours.
  • The store's help articles live on view.knowledge (enabled, query, results, loading, article), with actions.searchKnowledge, openArticle and closeArticle. enabled is true when the store has at least one published article. An article links to /guides/{category}/{slug} when that page exists. Otherwise the panel shows its sanitized body inline.

The platform widget (InboxWidget) shows an empty thread as a greeting card and one Help section: a search field, then up to three suggested articles. InboxMessageList draws that empty state when help articles are on. InboxConversation replaces the list with InboxKnowledgeArticle while an article is open. "Still need help? Send a message" closes the article and focuses the composer. In the Customizer, the help search returns sample results. The launcher stays visible on desktop while the panel is open, and hides on screens narrower than 640px.

Stable classes

Restyle from src/styles/theme.css with :where(), same as the other chrome hooks. See Chrome stable classes.

ClassNode
inbox-rootfixed wrapper (data-poltura-inbox, data-open, data-online, data-connection)
inbox-launcherlauncher button (aria-expanded, data-unread)
inbox-launcher__badgeunread count pill on the launcher
inbox-paneldialog
inbox-panel__headerheader row
inbox-panel__titleheader title
inbox-panel__statusone-line reply-time / offline status
inbox-panel__status-dotonline (green) / offline (grey) dot
inbox-panel__closeheader close icon button
inbox-messagesrole="log"
inbox-greetingempty-thread greeting card
inbox-helpempty-thread Help section (search and suggestions)
inbox-help__labelthe single "Help" section label
inbox-message-rowmessage wrapper containing author, bubble and metadata; --system for centred system text
inbox-messageactual bubble only; plus --customer, --staff, --ai
inbox-message__authorstaff / AI name row
inbox-message__disclosureAI disclosure line
inbox-message__metarelative time and delivery ticks
inbox-message__timerelative timestamp
inbox-message__ticksdelivery copy on the last customer message
inbox-dayoptional day separator in the log
inbox-typingthree-dot typing indicator
inbox-jumpjump-to-latest control
inbox-composercomposer form
inbox-composer__inputauto-growing textarea
inbox-composer__attachpaperclip button
inbox-composer__sendpaper-plane submit
inbox-composer__chippending attachment chip
inbox-statusreconnecting / preview bar
inbox-offlineoffline capture form
inbox-offline--successoffline form success copy
inbox-knowledge-searchhelp search field and results
inbox-knowledge-suggestionsempty-thread article rows
inbox-knowledge-articleopen article panel
inbox-knowledge-article__bodysanitized article HTML
inbox-knowledge-article__backarticle back control
inbox-knowledge-article__cta"Still need help" control

Colours are CSS variables on the root: --inbox-accent, --inbox-accent-text, --inbox-bg and --inbox-text.

Settings

The theme settings group chat (and chat_dark for the dark mode colours) styles the widget in the Customizer. It does not turn chat on for the store: that is the store's Inbox setting.

SettingWhat it does
chat.enabledhides the launcher when false (selecting the chat in the Customizer still opens it)
chat.positionright or left
chat.appearance_modeauto, light, dark
chat.accent / accent_text / background / textpanel colours
chat.launcher_label / title / greeting / offline_messagecopy overrides

Selecting the chat in the Customizer opens the panel on sample data. InboxRoot does this, so theme code needs nothing for it.

Next

Last updated