QuikChat CSS Architecture

April 4, 2026 · View on GitHub

QuikChat CSS is split into two layers: base (structural) and theme (appearance). This document explains the design and how to write custom themes.

Base CSS — Structure and Layout

Base styles control how the widget is laid out and sized. They do not vary between themes.

SelectorResponsibility
.quikchat-baseFlex column container, sizing, overflow, base font
.quikchat-title-areaFixed-height title zone, padding, font size/weight
.quikchat-messages-areaFlexible-height scrollable message zone
.quikchat-messageMessage padding, text wrapping
.quikchat-user-labelUsername font weight
.quikchat-message-contentClass hook for theme styling on message body
.quikchat-input-areaFixed-height flex row for textbox + button
.quikchat-input-textboxFlexible-width textarea, font inheritance
.quikchat-input-send-btnButton sizing, font inheritance, cursor

Key structural decisions:

  • box-sizing: border-box is scoped to .quikchat-base and all descendants. This prevents padding from causing overflow regardless of what the host page sets.
  • flex: 1; min-height: 0 on the messages area lets it fill available space and shrink below its content height (required for overflow scrolling to work in flex layouts).
  • flex-shrink: 0 on title and input areas prevents them from compressing when the container is small.
  • font-family: inherit; font-size: inherit on textarea and button overrides browser defaults for form controls, so they match the widget's font.
  • min-width: min(200px, 100%) prevents the widget from overflowing parents smaller than 200px.

Theme CSS — Appearance

A theme is a class (e.g., .quikchat-theme-light) applied on the same element as .quikchat-base. Themes control how the widget looks, not how it's laid out.

Properties themes should set

CategoryProperties
Colorscolor, background-color
Bordersborder, border-top, border-bottom, etc.
Cornersborder-radius and its longhand variants
Shadowsbox-shadow
Interaction:hover, :active, :focus color overrides

Properties themes should NOT set

CategoryExamplesWhy
Spacingpadding, marginMoves elements, breaks layout
Typographyfont-size, font-weight, font-familyAlters text flow and element sizing
Layoutdisplay, flex-*, width, heightBreaks flex structure
InteractioncursorBehavioral, not visual

Writing a Custom Theme

A minimal theme only needs color declarations. Use the built-in themes as reference.

.quikchat-theme-custom {
    background-color: #ffffff;
    color: #333333;
    border: 1px solid #cccccc;
    border-radius: 8px;
}

.quikchat-theme-custom .quikchat-title-area {
    background-color: #f5f5f5;
    color: #333333;
}

.quikchat-theme-custom .quikchat-messages-area {
    background-color: #fafafa;
    color: #333333;
}

.quikchat-theme-custom .quikchat-messages-area-alt .quikchat-message:nth-child(odd) {
    background-color: #f0f0f0;
    border-radius: 4px;
}

.quikchat-theme-custom .quikchat-messages-area-alt .quikchat-message:nth-child(even) {
    background-color: #e8e8e8;
    border-radius: 4px;
}

.quikchat-theme-custom .quikchat-input-area {
    background-color: #ffffff;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.quikchat-theme-custom .quikchat-input-textbox {
    background-color: #ffffff;
    color: #333333;
    border: 1px solid #cccccc;
    border-radius: 4px;
}

.quikchat-theme-custom .quikchat-input-send-btn {
    background-color: #4caf50;
    color: #ffffff;
    border: none;
    border-radius: 4px;
}

.quikchat-theme-custom .quikchat-input-send-btn:hover {
    background-color: #43a047;
}

Apply it in JavaScript:

const chat = new quikchat('#container', onSend, {
    theme: 'quikchat-theme-custom'
});

Or switch at runtime:

chat.changeTheme('quikchat-theme-custom');

ARIA Accessibility

The widget includes these ARIA attributes:

ElementAttributeValue
.quikchat-messages-arearolelog
.quikchat-messages-areaaria-livepolite
.quikchat-messages-areaaria-labelChat messages
.quikchat-input-textboxaria-labelType a message

Base CSS provides outline focus indicators on the textbox (:focus) and button (:focus-visible) using currentColor, which adapts to whatever text color the theme sets. Themes can override focus colors as needed.