Skip to main content

Overview

The v7 UI Kit uses CSS custom properties (design tokens) for all visual styling. Every color, font, spacing value, and border radius is defined as a --cometchat-* variable. Components reference these tokens — never hardcoded values. Theming works through the data-theme attribute on the .cometchat wrapper div. The built-in light.css and dark.css files define token values for each theme. You can override any token to create custom themes.

Setting the Theme

Pass the theme prop to CometChatProvider:
This sets data-theme="dark" on the wrapper, which activates the dark theme CSS variables.

Switching Themes at Runtime

Use the useTheme hook inside any component within the provider:

Follow the System (OS) Theme

The UI Kit ships light and dark themes but does not follow the operating system’s color-scheme setting on its own — there is no theme="system". A fresh app stays on the default light theme even when the OS is in dark mode. To follow the OS, read prefers-color-scheme and drive the theme yourself. Seed the initial theme from the OS setting when you mount the provider:
src/main.tsx
Then keep it in sync at runtime by subscribing to the media query’s change event from inside the provider (so useTheme is available):
Call useFollowSystemTheme() from a component rendered inside CometChatProvider. If you also expose a manual toggle, stop calling setTheme from this hook once the user overrides the theme — otherwise the next OS change will revert their choice.

Customizing Tokens

Override CSS variables to change the look of all components at once:
src/cometchat-overrides.css
Import this file after the UI Kit styles:

Per-Theme Overrides

Target a specific theme with the data-theme selector. The data-theme attribute and the .cometchat class sit on the same wrapper <div>, so use the same-element selector .cometchat[data-theme="dark"] — not the descendant form [data-theme="dark"] .cometchat, which matches only a .cometchat nested inside another [data-theme] element and therefore misses the root wrapper:
Component-class overrides are descendants of the wrapper, so the descendant form is correct for them — e.g. [data-theme="dark"] .cometchat-message-list { … }. It’s only overriding tokens on the root wrapper that requires the same-element .cometchat[data-theme="dark"] selector.

Per-Component Overrides

Target a specific component by its BEM class name:
Or wrap the component in your own class:

Differentiating the Thread Panel

Some surfaces paint their own opaque token rather than inheriting a background from their wrapper. The clearest example is the thread panel: its CometChatMessageList fills itself with --cometchat-message-list-bg (default --cometchat-background-color-03), while the thread header uses --cometchat-thread-header-background (which falls back to --cometchat-background-color-01). Because the list background is opaque, setting a background on the wrapping <div> has no visible effect — the list paints over it, and the panel looks mismatched against its header and composer. To style such a surface, override its own token instead of a wrapper background. For example, to make the thread panel’s message list match its header:

Design Token Categories

Colors

Semantic Colors

Typography

Spacing & Layout

Buttons


Component CSS Classes

The UI Kit uses plain, unhashed BEM class names in the DOM. All component class names follow the pattern cometchat-{component} with BEM modifiers (e.g., cometchat-message-bubble__content--outgoing). You can target them directly with standard class selectors.

What Works

1. The .cometchat wrapper class — the root div. Override tokens here to affect all components:
2. Plain class selectors — target any component by its BEM class name:
3. Wrap in your own class — add a wrapper div with your own class and set tokens there:
CSS variable overrides work at any level of the tree. Set them on .cometchat (the root wrapper) to affect all components, or use class selectors / wrapper classes to scope the change. Variables cascade down — a value set on a parent will be inherited by all CometChat components within it.

Creating a Custom Theme

Define a complete set of tokens under a custom data-theme value:
src/themes/brand.css
Then pass your theme name:
When creating a custom theme, start from the light or dark theme file and override only what you need. Unset tokens will fall back to the :root defaults (light theme).

Next Steps

Color Resources

Full color token reference with swatches

Message Bubble Styling

Customize bubble appearance, alignment, and spacing