Skip to content

Theme & Appearance ​

Mini Apps support automatic adaptation to the user's light/dark theme and provide rich theme color parameters and CSS variables.

ThemeParams ​

The ThemeParams object contains the color parameters of the client's current theme. Accessed via aiaxchat.WebApp.themeParams.

Color Properties ​

PropertyTypeDescription
bg_colorStringBackground color
text_colorStringPrimary text color
hint_colorStringHint text color
link_colorStringLink color
button_colorStringButton background color
button_text_colorStringButton text color
secondary_bg_colorStringSecondary background color
header_bg_colorStringHeader bar background color. Bot API 7.10+
bottom_bar_bg_colorStringBottom bar background color. Bot API 7.10+
accent_text_colorStringAccent text color. Bot API 7.10+
section_bg_colorStringSection background color. Bot API 7.10+
section_header_text_colorStringSection header text color. Bot API 7.10+
section_separator_colorStringSection separator color. Bot API 7.10+
subtitle_text_colorStringSubtitle text color. Bot API 7.10+
destructive_text_colorStringDestructive action text color. Bot API 7.10+

CSS Variables ​

The Mini App SDK automatically injects all theme colors as CSS variables, which can be used directly in stylesheets:

css
.my-element {
  background-color: var(--aiaxchat-theme-bg-color);
  color: var(--aiaxchat-theme-text-color);
}

.my-button {
  background-color: var(--aiaxchat-theme-button-color);
  color: var(--aiaxchat-theme-button-text-color);
}

.my-link {
  color: var(--aiaxchat-theme-link-color);
}

.my-hint {
  color: var(--aiaxchat-theme-hint-color);
}

Full CSS variable list:

CSS VariableCorresponding Property
--aiaxchat-theme-bg-colorbg_color
--aiaxchat-theme-text-colortext_color
--aiaxchat-theme-hint-colorhint_color
--aiaxchat-theme-link-colorlink_color
--aiaxchat-theme-button-colorbutton_color
--aiaxchat-theme-button-text-colorbutton_text_color
--aiaxchat-theme-secondary-bg-colorsecondary_bg_color
--aiaxchat-theme-header-bg-colorheader_bg_color
--aiaxchat-theme-bottom-bar-bg-colorbottom_bar_bg_color
--aiaxchat-theme-accent-text-coloraccent_text_color
--aiaxchat-theme-section-bg-colorsection_bg_color
--aiaxchat-theme-section-header-text-colorsection_header_text_color
--aiaxchat-theme-section-separator-colorsection_separator_color
--aiaxchat-theme-subtitle-text-colorsubtitle_text_color
--aiaxchat-theme-destructive-text-colordestructive_text_color

Listening for Theme Changes ​

javascript
aiaxchat.WebApp.onEvent('themeChanged', () => {
  const theme = aiaxchat.WebApp.themeParams;
  console.log('Background color:', theme.bg_color);
  console.log('Theme mode:', aiaxchat.WebApp.colorScheme);
});

SafeAreaInset ​

The SafeAreaInset object describes the device safe area insets (such as notch and rounded corner areas). Accessed via aiaxchat.WebApp.safeAreaInset. Bot API 8.0+

PropertyTypeDescription
topIntegerTop safe area inset in pixels
bottomIntegerBottom safe area inset in pixels
leftIntegerLeft safe area inset in pixels
rightIntegerRight safe area inset in pixels

Example ​

javascript
const inset = aiaxchat.WebApp.safeAreaInset;
document.body.style.paddingTop = inset.top + 'px';
document.body.style.paddingBottom = inset.bottom + 'px';

ContentSafeAreaInset ​

The ContentSafeAreaInset object describes the content safe area insets (excluding space occupied by the Mini App's own UI elements). Accessed via aiaxchat.WebApp.contentSafeAreaInset. Bot API 8.0+

PropertyTypeDescription
topIntegerTop content safe area inset in pixels
bottomIntegerBottom content safe area inset in pixels
leftIntegerLeft content safe area inset in pixels
rightIntegerRight content safe area inset in pixels

Example ​

javascript
const contentInset = aiaxchat.WebApp.contentSafeAreaInset;

// Combine with device safe area
const safeInset = aiaxchat.WebApp.safeAreaInset;
const totalTop = safeInset.top + contentInset.top;

document.querySelector('.content').style.paddingTop = totalTop + 'px';