Docsโ€บChatโ€บGuidesโ€บTheming

Theming

@ngaf/chat uses CSS custom properties (variables) for all visual styling. Every color, radius, font, and spacing value is controlled by a variable prefixed with --ngaf-chat-, making it straightforward to match your application's design system.

How Theming Works

Chat components define all design tokens using CSS custom properties on the :host element. The token system supports automatic light/dark switching via prefers-color-scheme and explicit override via a [data-ngaf-chat-theme] attribute.

No imported stylesheet is needed โ€” tokens are applied automatically by each component's encapsulated styles. An optional global stylesheet (@ngaf/chat/chat.css) is available if you want to customize tokens at the :root level.

CSS Custom Properties Reference

Colors

TokenLightDarkPurpose
--ngaf-chat-bgrgb(255 255 255)rgb(17 17 17)Page/window background
--ngaf-chat-surfacergb(255 255 255)rgb(28 28 28)Cards, elevated surfaces
--ngaf-chat-surface-altrgb(251 251 251)rgb(44 44 44)Input bg, subtle fills
--ngaf-chat-primaryrgb(28 28 28)rgb(255 255 255)User-bubble bg, button fg
--ngaf-chat-on-primaryrgb(255 255 255)rgb(28 28 28)User-bubble text, button bg
--ngaf-chat-textrgb(28 28 28)rgb(245 245 245)Assistant text, headings
--ngaf-chat-text-mutedrgb(115 115 115)rgb(160 160 160)Labels, placeholders
--ngaf-chat-separatorrgb(229 229 229)rgb(45 45 45)Hairlines, borders
--ngaf-chat-mutedrgb(200 200 200)rgb(60 60 60)Disabled state
--ngaf-chat-error-bg#fef2f2rgb(45 21 21)Error background
--ngaf-chat-error-text#dc2626#fca5a5Error text
--ngaf-chat-warning-bg#fffbebrgb(45 35 21)Warning background
--ngaf-chat-warning-text#b45309#fbbf24Warning text
--ngaf-chat-success#16a34a#4ade80Success state

Shape & Layout

TokenLightDarkPurpose
--ngaf-chat-radius-bubble15pxโ€”User message bubble radius
--ngaf-chat-radius-input20pxโ€”Input pill radius
--ngaf-chat-radius-card8pxโ€”Card / trace radius
--ngaf-chat-radius-button8pxโ€”Button radius
--ngaf-chat-radius-launcher9999pxโ€”Circular launcher button
--ngaf-chat-max-width48remโ€”Message column max width

Typography

TokenLightDarkPurpose
--ngaf-chat-font-familysystem stackโ€”Default font
--ngaf-chat-font-monomono stackโ€”Code blocks
--ngaf-chat-font-size1remโ€”Message text
--ngaf-chat-font-size-sm0.875remโ€”UI controls
--ngaf-chat-font-size-xs0.75remโ€”Labels, metadata
--ngaf-chat-line-height1.6โ€”Assistant text
--ngaf-chat-line-height-tight1.5โ€”User bubble

Light and Dark Mode

Tokens default to light values. Dark mode activates automatically when the user's system preference is prefers-color-scheme: dark, unless the host element has data-ngaf-chat-theme="light" set.

The switching logic is:

  1. Light variables are applied by default on :host
  2. @media (prefers-color-scheme: dark) overrides with dark variables, unless data-ngaf-chat-theme="light" is set
  3. [data-ngaf-chat-theme="dark"] forces dark variables regardless of system preference

Customizing the Theme

Override a single token at app root

/* src/styles.css */
:root {
  --ngaf-chat-primary: oklch(0.55 0.22 264);
}

Force a theme via attribute

<!-- Force dark mode regardless of system preference -->
<chat data-ngaf-chat-theme="dark" [agent]="agent" />
 
<!-- Force light mode regardless of system preference -->
<chat data-ngaf-chat-theme="light" [agent]="agent" />

Deep override via the optional global stylesheet

Import @ngaf/chat/chat.css in your global styles to get a :root-level baseline you can override:

/* src/styles.css */
@import '@ngaf/chat/chat.css';
 
:root {
  --ngaf-chat-primary: oklch(0.55 0.22 264);
  --ngaf-chat-radius-bubble: 10px;
}

Brand Color Example

:root {
  /* Brand blues */
  --ngaf-chat-primary: #2563eb;
  --ngaf-chat-on-primary: #ffffff;
 
  /* Softer corners */
  --ngaf-chat-radius-bubble: 12px;
  --ngaf-chat-radius-input: 16px;
 
  /* Wider content area */
  --ngaf-chat-max-width: 56rem;
}

Migration from --chat-* Tokens

If you previously customized --chat-* tokens, rename them to --ngaf-chat-*. Examples:

Old tokenNew token
--chat-bg--ngaf-chat-bg
--chat-text--ngaf-chat-text
--chat-user-bg--ngaf-chat-primary
--chat-user-text--ngaf-chat-on-primary
--chat-radius-message--ngaf-chat-radius-bubble
--chat-radius-input--ngaf-chat-radius-input
--chat-radius-card--ngaf-chat-radius-card
--chat-max-width--ngaf-chat-max-width
--chat-error-bg--ngaf-chat-error-bg
--chat-error-text--ngaf-chat-error-text
--chat-warning-bg--ngaf-chat-warning-bg
--chat-warning-text--ngaf-chat-warning-text
--chat-success--ngaf-chat-success
CHAT_THEME_STYLES removed

The CHAT_THEME_STYLES and CHAT_MARKDOWN_STYLES named exports no longer exist in @ngaf/chat. Remove any imports of those constants โ€” theme tokens are now applied automatically by each component.