Host app integration
CSS, modals and style isolation when the chat is installed in another project - an admin template or a custom shell.
Use this page when chat works on one page but modals look broken, popups don't appear, or you worry the package will overwrite your app's CSS.
How chat styling is isolated
Chat does not inject global class names like .btn or .modal that would clash with Bootstrap, Ant or MUI.
Required setup
Same as CSS setup - import the stylesheet once in your global CSS:
@import "@realtimexsco/live-chat/styles.css";No @source or chat-specific config - styles.cssalready contains every class the chat's components need.
Recommended page layout
Full-screen page:
<div className="h-dvh min-h-0 overflow-hidden"> <ChatMain {...chatConfig} viewportHeight="screen" /></div>Admin shell with a fixed header (~4rem):
<ChatMain {...chatConfig} viewportHeight="calc(100dvh - 4rem)" />Inside your own flex column:
<div className="flex min-h-0 flex-1 overflow-hidden"> <ChatMain {...chatConfig} viewportHeight="full" /></div>Why modals don't open or look wrong
Browser check (2 minutes)
- Open the modal (New chat, Forward, Attachments preview, …).
- DevTools → Elements → search for
data-slot="dialog-content". Not in the DOM → React/state issue. In the DOM but not visible → CSS, z-index or animation issue. - Computed styles on that element: no
position: fixed→styles.cssnot imported (or stale);z-indexlower than the sidebar → stacking issue; transparent background →--chat-surface/styles.cssmissing.
z-index with host sidebars
Chat overlays (dialogs, alert dialogs, header menus, tooltips) use z-[200]. If your shell uses a higher stack (e.g. z-[1000]), chat modals can appear hidden.
Option A - host override(safest when you can't change the shell):
/* Host globals.css - after the package import */[data-slot="dialog-overlay"],[data-slot="dialog-content"],[data-slot="alert-dialog-overlay"],[data-slot="alert-dialog-content"] { z-index: 9999 !important;}Option B - customization (raise in-panel drawers only):
export const chatClassNames = { drawer: "z-[9999]", drawerContent: "rounded-l-2xl",};CSS import order
/* Your app base tokens first (optional) */:root { --background: …; --foreground: …;} /* Package chat tokens + component styles */@import "@realtimexsco/live-chat/styles.css"; /* Your overrides last */:root { --chat-theme: #your-brand;}Local file: / npm link workflow
cd /path/to/realtimex-npm-packagenpm run build # required after every source change cd /path/to/host-appnpm install # refresh the file: link# restart the host dev serverIf CSS or classes look outdated, the host is almost always serving an old dist/.
Next.js reminders
"use client"on the chat page.transpilePackages: ["@realtimexsco/live-chat"]innext.config.ts.
What the package does not require
- Installing Lexical, DOMPurify, Radix or Zustand separately in the host app.
- Copying chat component CSS into your repo.
- Wrapping pages in chat-specific providers beyond
<ChatMain />(providers are internal).