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
| Token | Light | Dark | Purpose |
|---|---|---|---|
--ngaf-chat-bg | rgb(255 255 255) | rgb(17 17 17) | Page/window background |
--ngaf-chat-surface | rgb(255 255 255) | rgb(28 28 28) | Cards, elevated surfaces |
--ngaf-chat-surface-alt | rgb(251 251 251) | rgb(44 44 44) | Input bg, subtle fills |
--ngaf-chat-primary | rgb(28 28 28) | rgb(255 255 255) | User-bubble bg, button fg |
--ngaf-chat-on-primary | rgb(255 255 255) | rgb(28 28 28) | User-bubble text, button bg |
--ngaf-chat-text | rgb(28 28 28) | rgb(245 245 245) | Assistant text, headings |
--ngaf-chat-text-muted | rgb(115 115 115) | rgb(160 160 160) | Labels, placeholders |
--ngaf-chat-separator | rgb(229 229 229) | rgb(45 45 45) | Hairlines, borders |
--ngaf-chat-muted | rgb(200 200 200) | rgb(60 60 60) | Disabled state |
--ngaf-chat-error-bg | #fef2f2 | rgb(45 21 21) | Error background |
--ngaf-chat-error-text | #dc2626 | #fca5a5 | Error text |
--ngaf-chat-warning-bg | #fffbeb | rgb(45 35 21) | Warning background |
--ngaf-chat-warning-text | #b45309 | #fbbf24 | Warning text |
--ngaf-chat-success | #16a34a | #4ade80 | Success state |
Shape & Layout
| Token | Light | Dark | Purpose |
|---|---|---|---|
--ngaf-chat-radius-bubble | 15px | โ | User message bubble radius |
--ngaf-chat-radius-input | 20px | โ | Input pill radius |
--ngaf-chat-radius-card | 8px | โ | Card / trace radius |
--ngaf-chat-radius-button | 8px | โ | Button radius |
--ngaf-chat-radius-launcher | 9999px | โ | Circular launcher button |
--ngaf-chat-max-width | 48rem | โ | Message column max width |
Typography
| Token | Light | Dark | Purpose |
|---|---|---|---|
--ngaf-chat-font-family | system stack | โ | Default font |
--ngaf-chat-font-mono | mono stack | โ | Code blocks |
--ngaf-chat-font-size | 1rem | โ | Message text |
--ngaf-chat-font-size-sm | 0.875rem | โ | UI controls |
--ngaf-chat-font-size-xs | 0.75rem | โ | Labels, metadata |
--ngaf-chat-line-height | 1.6 | โ | Assistant text |
--ngaf-chat-line-height-tight | 1.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:
- Light variables are applied by default on
:host @media (prefers-color-scheme: dark)overrides with dark variables, unlessdata-ngaf-chat-theme="light"is set[data-ngaf-chat-theme="dark"]forces dark variables regardless of system preference
Customizing the Theme
Override a single token at app root
Force a theme via attribute
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:
Brand Color Example
Migration from --chat-* Tokens
If you previously customized --chat-* tokens, rename them to --ngaf-chat-*. Examples:
| Old token | New 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 |
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.