Appearance in code
Pass the required theme fields during initialization. Explicit values override the corresponding channel settings; other fields are inherited. Configuration priority.
Appearance
theme supports:
| Key | What the visitor sees |
|---|---|
chat_title |
Header title while the widget is loading. Does not replace the title of an open dialog. |
default_dialog_title |
Fallback title in the history and header when neither a custom dialog title nor an agent or operator name is available; also labels an operator whose name is unknown. See where the texts appear. |
theme_mode |
Light, dark, or system theme: light, dark, auto. |
position |
Popup position: bottom-right, bottom-left, top-right, top-left. |
width, height |
Window size: width 200–800, height 300–1000 pixels. |
border_radius |
Corner radius from 0 to 50 pixels. |
shadow_enabled |
Window shadow. |
welcome_message |
Placeholder in the message input. |
empty_state_message |
Greeting in an empty new dialog. |
welcome_buttons |
Quick questions before the conversation starts. |
welcome_icon_url |
Image above the greeting: an absolute HTTP(S) URL of up to 2048 characters. An empty string restores the default icon. |
welcome_icon_shape |
Image shape: circle (default) or square (without rounded corners). |
button |
Floating-button position and colors. |
colors |
Window colors for light and dark separately: each theme accepts optional background and accent values in #RRGGBB format. Omitted values inherit channel settings; without overrides, the default appearance is used. |
Localized text accepts { ru?: string, en?: string }. Each welcome_buttons array may contain up to 8 non-empty unique strings of no more than 120 characters. Clicking a button immediately sends its text.
SenlerWidget.init({
channel_id: "xxx",
theme: {
empty_state_message: {
ru: "Здравствуйте! Чем помочь?",
en: "Hello! How can I help?",
},
welcome_buttons: {
ru: ["Узнать цену", "Связаться с оператором"],
en: ["Check the price", "Contact an operator"],
},
},
});
theme.button.position accepts the same four positions plus hidden. Use theme.button.position: "hidden" to hide the floating button; theme.position: "hidden" is invalid. Set theme.button.light.background, theme.button.light.icon, theme.button.dark.background, and theme.button.dark.icon in #RRGGBB format.
Window colors (theme.colors) and floating-button colors (theme.button) are configured independently. Switching themes selects the corresponding light or dark palette without resetting its colors. Set palettes in channel settings or init; configure can switch themes but cannot replace the palettes themselves.
welcome_buttons cannot be changed through configure. Save them in the cabinet or supply an override in init, then initialize the widget again.
Website and Widget Themes
theme.theme_mode: "auto" follows the visitor's browser preference. It does not restore the theme from channel settings. The widget also does not read the website's CSS classes or its custom theme switcher's state.
To follow a custom switcher, pass the website's current theme, light or dark, during initialization. Call configure whenever it changes:
SenlerWidget.init({
channel_id: "xxx",
theme: { theme_mode: "light" },
});
// In the handler that switches the website to its dark theme:
SenlerWidget.configure({ themeMode: "dark" });
The example starts with a light website theme. If your switcher offers an Auto option, pass the light or dark theme already resolved by the website, or use auto when both should follow the browser preference.
If resolveRuntime selects the theme, update the data that function reads and call refreshRuntime(). While it returns theme_mode, that value takes priority over configure({ themeMode }). For the React component, pass the current theme through settings.themeMode; reinitialization is not needed.
Image above the greeting
You can upload your logo or illustration in channel settings. To set the image from site code, pass its URL in theme.welcome_icon_url:
SenlerWidget.init({
channel_id: "xxx",
theme: {
welcome_icon_url: "https://example.com/support.png",
welcome_icon_shape: "circle",
},
});
The image is used in centered_text mode before a dialog is selected and in an empty dialog. It does not replace message avatars or the floating button icon. The image fills a square area with cropping at the edges; circle clips that area to a circle. If the file fails to load, the widget shows the default icon. Use an HTTPS image URL on an HTTPS website.
Set welcome_icon_url: "" to restore the default icon. Merely removing the field from init preserves the value from channel settings. Both icon parameters are initialization settings, not configure fields: initialize the widget again with the desired theme to change them.
Greeting selection is described in Dynamic messages. Change the theme and border radius of a running instance with configure; this does not change channel settings.
Settings for a Custom Editor
If you build your own appearance editor or preview, the @senlerio/widget/appearance module from the Widget package provides the same defaults and layout calculations as the widget. It is not required for an ordinary chat installation.
import type { SenlerWidgetTheme } from "@senlerio/widget";
import {
WIDGET_APPEARANCE_DEFAULTS,
mergeThemeConfig,
getWidgetWindowLayout,
} from "@senlerio/widget/appearance";
const theme = mergeThemeConfig<SenlerWidgetTheme>(WIDGET_APPEARANCE_DEFAULTS, {
width: 480,
colors: { light: { accent: "#2563EB" } },
}) ?? WIDGET_APPEARANCE_DEFAULTS;
const layout = getWidgetWindowLayout(theme, { width: 390, height: 844 });
mergeThemeConfig(base, override) combines explicitly provided values while preserving other translations, colors, and button settings from base. An undefined value does not erase the base setting. The function does not fetch channel settings or change a running widget.
getWidgetWindowLayout returns width, height, left, and top in pixels: the window is constrained to the available area with margins. WidgetViewport accepts the area's dimensions and optional offsetLeft and offsetTop offsets. getWidgetCornerStyles(position, inset) returns CSS offsets for the selected corner.
The module also exports WIDGET_DEFAULT_COLORS, WIDGET_DEFAULT_BUTTON_COLORS, WIDGET_WINDOW_MARGIN, WIDGET_BUTTON_SIZE, and WIDGET_WINDOW_SHADOWS. These support your own rendering; to apply settings to the chat, pass theme to init or supported fields to configure.