Skip to main content
Create and apply one CometChat UI Kit theme that matches your brand in light and dark appearance.

When to use this

  • You want every UI Kit screen to use your brand colour.
  • You need light and dark appearance with consistent colours.
  • You want to change background, text, stroke or icon colours, or the font, across every component.

Prerequisites


Core Concepts

Both toolkits read one token table in CometChatCore, so a token is the same colour in SwiftUI and in UIKit. Only the way you set the theme differs.
CometChatTheme is a value carried in the SwiftUI environment.
  • theme.light and theme.dark — a CometChatColorScheme each, 56 colour tokens. The one matching the environment’s colorScheme is used.
  • theme.typography — CometChatTypography, 28 font tokens.
  • theme.shapes — CometChatShapes, five corner radii.
  • .cometChatTheme(_:) sets it for a view and everything below it, so different parts of an app can use different themes.
Precedence: a component’s style: argument, then the theme, then the Kit default.

Quick Start

1

Build a theme

2

Apply it at the root

3

Build and verify

Run the app and check the Kit’s screens in both light and dark appearance.
Conversations with the default CometChat theme in light appearance

Default

Conversations with a brand colour driving the whole derived palette

Brand colour

Conversations in dark appearance

Dark appearance


Change the Primary Color

One brand colour derives primary, every token defined as primary, and the ten-step extendedPrimary ramp — each step mixes the colour toward white (light) or black (dark). The middle screenshot above is that ramp derived from one colour, with nothing else set.
UIKit Conversations with the default theme

UIKit — default

UIKit Conversations after setting a brand colour on the shared theme

UIKit — setBrandColor(_:)


Customize Common Theme Tokens

Every token stays individually settable after deriving.
CometChatColorScheme is a value: a token you set is that colour, whatever it was derived from.

Add Dark Mode Support

Dark appearance is built in: both toolkits ship a dark palette and switch with the system. Override it only where your brand differs.
theme.dark is used when the environment’s colorScheme is .dark:

Apply a Theme to a Specific Screen

The theme is scoped to the view you set it on, so a nested .cometChatTheme(_:) wins for its subtree:

Typography

28 tokens: each level in bold, medium and regular, in the system font.
Build the whole scale in your font family, or replace one token:
The Kit’s own sizes scale with Dynamic Type on the UIFontMetrics.default curve, with no upper limit. Lay out your own views around Kit text so they hold at the largest accessibility sizes.

Shapes

CometChatShapes carries five radii — extraSmall 4, small 8, medium 12, large 16, extraLarge 28 — as theme.shapes in the SwiftUI toolkit. The UIKit theme has no shape tokens; corner radii are set per component through its style.

Color Token Reference

The tokens you reach for most. Color Resources lists all 56 with their light and dark values.

Contrast

A few of the palette’s pairings sit under WCAG AA: tertiary text and the secondary icon tint (#A1A1A1) on white, the warning self-mention, the error text on background2. If you need AA throughout, override the tokens involved — for example textTertiary and iconTintSecondary — and check each pair you create: tertiary text sits on background3 in the search field, the tightest combination in the Kit.

Next Steps

Color Resources

Every colour token with its light and dark value.

Component Styling

Style one component without changing the theme.

Message Bubble Styling

Incoming, outgoing and per-kind bubble styles.

Localize

Languages and date formats.