Skip to content

Themes

The Chotto library uses a flexible theme system for customizing the interface appearance. The system supports several ready-made themes and allows creating custom themes through CSS variables.

Available Themes

The library includes four ready-made themes:

  • Default (light) — default light theme
  • Dark — dark theme with neutral colors
  • Green — green theme with emerald accents
  • Mobilon1 — Mobilon brand theme

Importing Themes

Basic Import

javascript
// Import main library styles
import '@mobilon-dev/chotto/style.css'

Import Specific Theme

If you need a specific theme, you can import separately:

javascript
import '@mobilon-dev/chotto/themes/default.css'
import '@mobilon-dev/chotto/themes/dark.css'
import '@mobilon-dev/chotto/themes/green.css'
import '@mobilon-dev/chotto/themes/mobilon1.css'

Variable System

The library uses a two-level CSS variable system:

1. Global Theme Variables (--chotto-theme-*)

Global variables affect the entire chat interface. They are defined through the data-theme attribute:

css
[data-theme="default"] {
  /* Main colors */
  --chotto-theme-primary-color: #ffffff;
  --chotto-theme-secondary-color: #faf6f4;
  --chotto-theme-tertiary-color: #a3a3a3;
  
  /* Text colors */
  --chotto-theme-primary-text-color: #1e1e1e;
  --chotto-theme-secondary-text-color: #5f5f5f;
  
  /* Typography */
  --chotto-theme-font-family: 'Montserrat', sans-serif;
  --chotto-theme-header-font-size: 20px;
  --chotto-theme-text-font-size: 15px;
  
  /* Messages */
  --chotto-theme-message-right-bg: #d1fae5;
  --chotto-theme-message-left-bg: #e5e5e5;
  
  /* ... and other variables (82 variables total) */
}

2. Component Variables (--chotto-componentname-*)

Each component has its own CSS variables that can be overridden in your project. For example, for the CommunicationPanel component:

css
[data-theme="default"] {
  /* CommunicationPanel component variables */
  --chotto-communicationpanel-background: #ffffff;
  --chotto-communicationpanel-border-color: #e5e5e5;
  --chotto-communicationpanel-btn-active-color: #007CFF;
  --chotto-communicationpanel-btn-hover-background: #f5f5f5;
  --chotto-communicationpanel-menu-background: #ffffff;
  /* ... and other component variables */
}

Benefits of the two-level system:

  • ✅ Flexible customization of individual components
  • ✅ All variables have fallback values
  • ✅ Can use global theme variables: var(--chotto-theme-primary-color)
  • ✅ Full typing through TypeScript interfaces

Available data-theme values: "default", "dark", "green", "mobilon1"

TypeScript Types

All global theme variables are typed through the ChottoThemeVariables interface:

typescript
import type { ChottoThemeVariables } from '@mobilon-dev/chotto'

// Using the type for variable validation
const themeVariables: ChottoThemeVariables = {
  '--chotto-theme-primary-color': '#ffffff',
  '--chotto-theme-secondary-color': '#faf6f4',
  // ... rest of variables
}

Component variables are typed in interfaces of the form ComponentNameThemeCSSVariables in the corresponding components.

Global Theme Variables

Main Colors

NamePurpose
--chotto-theme-primary-colorMain color used in chat (most often background)
--chotto-theme-secondary-colorSecondary color
--chotto-theme-tertiary-colorTertiary color
--chotto-theme-quaternary-colorQuaternary color
--chotto-theme-quinary-colorQuinary color
--chotto-theme-primary-text-colorMain text color
--chotto-theme-secondary-text-colorAdditional text color

Semantic Colors

NamePurpose
--chotto-theme-shadow-colorStrong shadow color
--chotto-theme-shadow-light-colorShadow outline color for elements
--chotto-theme-status-color-receivedMessage status color — delivered to recipient
--chotto-theme-status-color-readMessage status color — read by recipient
--chotto-theme-status-color-errorMessage status color — send error
--chotto-theme-status-color-pendingMessage status color — sending

Typography

NamePurpose
--chotto-theme-font-familyFont family for entire chat
--chotto-theme-header-fontHeader font
--chotto-theme-header-font-sizeHeader font size
--chotto-theme-header-font-colorHeader font color
--chotto-theme-title-font-sizeAccent label font size
--chotto-theme-text-font-sizeMain text font size
--chotto-theme-additional-text-font-sizeAdditional text font size
--chotto-theme-small-text-font-sizeTertiary informational text font size
--chotto-theme-context-menu-font-sizeContext menu text font size
--chotto-theme-header-font-weightHeader font weight
--chotto-theme-title-font-weightAccent label font weight
--chotto-theme-default-font-weightDefault font weight for entire chat
--chotto-theme-small-text-font-weightSmall text font weight

Icon Sizes

NamePurpose
--chotto-theme-button-icon-sizeButton icon size
--chotto-theme-text-icon-sizeIcon size comparable to main text
--chotto-theme-small-text-icon-sizeSecondary icon size
--chotto-theme-avatar-small-sizeSmall avatar diameter
--chotto-theme-avatar-medium-sizeMedium avatar diameter

Buttons

NamePurpose
--chotto-theme-button-color-activeActive button color
--chotto-theme-button-color-hoverButton color on mouse hover
--chotto-theme-button-color-disabledDisabled button color
--chotto-theme-action-button-color-activeActive action button color
--chotto-theme-action-button-color-hoverAction button color on hover
--chotto-theme-action-button-color-disabledDisabled action button color

Element States

NamePurpose
--chotto-theme-item-background-color-focusSelected tile element background color
--chotto-theme-item-background-color-hoverTile element background color on mouse hover
--chotto-theme-item-border-colorBorder color for internal chat elements
--chotto-theme-unread-background-colorUnread messages indicator background color
--chotto-theme-unread-text-colorUnread messages indicator label color

Borders

NamePurpose
--chotto-theme-borderThickness, line type and color for container and layout borders

Scrollbar

NamePurpose
--chotto-theme-scrollbar-bgScrollbar color
--chotto-theme-scrollbar-thumb-bgScrollbar thumb color showing current page position

Messages

General Message Variables

NamePurpose
--chotto-theme-message-right-bgBackground of message positioned on the right
--chotto-theme-message-right-secondary-bgSecondary color for messages positioned on the right
--chotto-theme-message-left-bgBackground of message positioned on the left
--chotto-theme-message-left-secondary-bgSecondary color for messages positioned on the left
--chotto-theme-message-accent-line-colorAccent separator color for accompanying content from main message
--chotto-theme-message-focused-colorMessage highlight color when searching
--chotto-theme-message-marginMessage container margin
--chotto-theme-message-type-icon-bg-colorMessage type icon background color
--chotto-theme-message-type-icon-colorMessage type icon color
--chotto-theme-message-border-radiusMessage corner radius

Message Modal Windows

NamePurpose
--chotto-theme-message-modal-paddingInternal padding from modal window edge
--chotto-theme-message-modal-border-radiusModal window corner radius
--chotto-theme-message-modal-mask-backgroundMask color surrounding modal window
--chotto-theme-message-modal-overlay-shadowbox-shadow setting for modal window outline
--chotto-theme-message-modal-bgModal window background color

Component Variables

Each component has its own specific CSS variables with the prefix --chotto-componentname-*. These variables can be overridden to customize individual components.

Component Variable Examples

CommunicationPanel

css
--chotto-communicationpanel-background: #ffffff;
--chotto-communicationpanel-border-color: #e5e5e5;
--chotto-communicationpanel-btn-active-color: #007CFF;
--chotto-communicationpanel-btn-hover-background: #f5f5f5;
--chotto-communicationpanel-menu-background: #ffffff;

ChatInput

css
--chotto-chat-input-container-bg: #ffffff;
--chotto-chat-input-icon-color: #007CFF;
--chotto-chat-input-icon-color-disabled: #b4e8f9;

Tooltip

css
--chotto-tooltip-text-color: #ffffff;
--chotto-tooltip-bg-color: #262626;

WABATemplateSelector

css
--chotto-variable-placeholder-empty-color: #f5f5f5;
--chotto-variable-placeholder-filled-color: #e5e5e5;

WABAAttachmentSection

css
--chotto-attachment-section-color: #f5f5f5;
--chotto-attachment-section-hover-color: #e5e5e5;
--chotto-attachment-section-error-color: #dc2626;

WABAQuickReplyButtons

css
--chotto-quick-reply-buttons-color: #1e1e1e;

The full list of component variables is typed in interfaces of the form ComponentNameThemeCSSVariables in the corresponding components.

Creating Custom Theme

To create a custom theme:

  1. Define variables in CSS with the data-theme attribute:
css
[data-theme="my-custom-theme"] {
  --chotto-theme-primary-color: #your-color;
  --chotto-theme-secondary-color: #your-color;
  /* ... rest of variables */
}
  1. Use TypeScript types for validation:
typescript
import type { ChottoThemeVariables } from '@mobilon-dev/chotto'

const myTheme: ChottoThemeVariables = {
  '--chotto-theme-primary-color': '#your-color',
  // ... rest of variables
}
  1. Apply theme to container:
vue
<template>
  <div data-theme="my-custom-theme">
    <BaseContainer>
      <!-- Your content -->
    </BaseContainer>
  </div>
</template>

Theme Validation

The library includes built-in theme validation:

bash
# Check theme consistency
npm run validate-themes

The validation script will show:

  • ❌ Missing variables
  • ⚠️ Extra variables
  • 📊 Theme statistics
  • 🔍 Detailed information

Additional Resources

  • Full list of global variables is available in the ChottoThemeVariables type from @mobilon-dev/chotto
  • Component variables are typed in interfaces of the form ComponentNameThemeCSSVariables in the corresponding components
  • Examples of theme usage can be found in Storybook