Custom fonts

|

View as Markdown

IMPORTANT

Advanced customization will be deprecated. It applies only to the legacy widget design.

Advanced customization lets you configure custom fonts for your Live Chat widget on a per-theme basis. Use any web font, including Google Fonts or a self-hosted font, as long as a CSS stylesheet URL is available.

Use custom fonts when you want the widget to match the typography of your brand. Custom fonts also help you meet accessibility requirements that Roboto (the built-in default font) does not satisfy.

How custom fonts work [#how-custom-fonts-work]

You declare fonts inside the advanced customization JSON under themes[themeName].fonts. When the widget loads, it retrieves the font stylesheet and waits for the font to be available. It then applies the font across the widget.

Font loading happens entirely inside the widget iframe. The widget loads the font from the Infobip domain. As a result, the Content Security Policy (CSP) of the host page does not apply. The font-src and style-src directives of your site do not interfere with widget font loading.



Configure fonts [#configure-fonts]

To configure a custom font:

  1. In the Infobip web interface, go to Live Chat > Widgets and open the widget that you want to configure.

  2. Make sure that Use the new widget design is turned off.

  3. In the Appearance section, go to Advanced customization and turn on Custom themes if it is not already on.

  4. In the JSON text area, add a fonts object inside your theme. If fonts is present, both fields are required:

    json
    1{
    2 "default": {
    3 "styles": {},
    4 "fonts": {
    5 "fontFaceUrl": "https://fonts.googleapis.com/css2?family=Inter&display=swap",
    6 "fontFamily": "Inter"
    7 }
    8 }
    9}
  5. Select Save. The widget uses the configured font the next time it loads.


Validation rules [#validation-rules]

The configuration must meet the following rules:

  • The JSON must be a valid JSON object.
  • A "default" theme must always be present.
  • If a theme includes a fonts object, both fontFaceUrl and fontFamily are required. If you provide only one field, a validation error occurs and Live Chat does not save the configuration.


Font configuration reference [#font-configuration-reference]

The fonts object contains the following fields:

FieldTypeRequiredDescription
fontFaceUrlstringYes (if fonts is present)URL of a CSS stylesheet that declares the @font-face rule. This is typically a Google Fonts or Adobe Fonts CSS URL. Must be a fully qualified URL.
fontFamilystringYes (if fonts is present)The CSS font-family value to apply. Must match the family name exposed by the stylesheet at fontFaceUrl.

The following notes apply to these fields:

  • fontFaceUrl must point to a CSS stylesheet: Do not use a font binary (.ttf, .woff2, and similar). Google Fonts and Adobe Fonts both serve CSS URLs. If you self-host fonts, make sure the URL returns a CSS file with a valid @font-face declaration.
  • The back end does not validate the font URL: If the URL is unreachable or returns an error, the widget falls back to Arial, Helvetica, or the browser's sans-serif font.
  • Roboto loads only when needed: If every theme defines its own fonts, the widget does not retrieve Roboto. This avoids an unnecessary network request.

JSON examples [#json-examples]

The following example configures two themes:

  1. The default theme uses a custom font.
  2. The dark theme uses the default font fallback (Roboto) because it does not define a fonts object.

The following JSON shows this configuration:

json
1{
2 "default": {
3 "styles": {
4 "lc-header-container-background-color": "#1a1a2e",
5 "lc-chat-message-user-bubble-background-color": "#16213e"
6 },
7 "fonts": {
8 "fontFaceUrl": "https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap",
9 "fontFamily": "Inter"
10 }
11 },
12 "dark": {
13 "styles": {
14 "lc-header-container-background-color": "#0f0f0f",
15 "lc-chat-message-user-bubble-background-color": "#1a1a1a"
16 }
17 }
18}

To apply a custom font to all themes, add a fonts object to each theme individually:

json
1{
2 "default": {
3 "fonts": {
4 "fontFaceUrl": "https://fonts.googleapis.com/css2?family=Inter&display=swap",
5 "fontFamily": "Inter"
6 }
7 },
8 "dark": {
9 "fonts": {
10 "fontFaceUrl": "https://fonts.googleapis.com/css2?family=Inter&display=swap",
11 "fontFamily": "Inter"
12 }
13 }
14}
NOTE

When multiple themes reference the same fontFaceUrl, the widget retrieves the stylesheet only once.



Font priority [#font-priority]

When the widget applies a theme, it resolves the font in the following order:

  1. Per-theme font: The fonts object defined on the active theme.
  2. Default font: Roboto, if the active theme does not define a fonts object.

If the fontFaceUrl of the active theme is unreachable or returns an error, the widget falls back to Arial, Helvetica, or the browser's sans-serif font.



Related pages

Custom themes
Enable advanced customization and define themes in JSON.

CSS variables
Look up every CSS variable that you can override in a theme.

Content Security Policy (CSP) in Live Chat
Review the CSP directives that the Live Chat widget requires.


Was this page helpful?