> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> Create and apply a CometChat iOS UI Kit v6 theme that matches your brand across light and dark appearance, in SwiftUI and UIKit.

> [accordion] AI Integration Quick Reference
>
> ```json theme={null}
> {
>   "products": ["CometChatSwiftUI", "CometChatUIKit"],
>   "swiftUI": {
>     "type": "CometChatTheme",
>     "apply": ".cometChatTheme(_:) or .environment(\\.cometChatTheme, _:) on any ancestor view",
>     "colours": "theme.light / theme.dark — CometChatColorScheme, 56 tokens",
>     "derive": "CometChatColorScheme.derived(primary:isDark:)",
>     "typography": "theme.typography — CometChatTypography, 28 tokens; CometChatTypography.derived(family:)",
>     "shapes": "theme.shapes — CometChatShapes, 5 radii"
>   },
>   "uiKit": {
>     "type": "CometChatUIKitTheme",
>     "apply": "CometChatUIKitTheme.shared (every screen) or a screen's `theme` property",
>     "colours": "56 UIColor properties, light/dark resolved by the trait collection",
>     "derive": "setBrandColor(_:)",
>     "typography": "28 UIFont properties"
>   },
>   "keyTokens": ["primary", "background1", "background2", "textPrimary", "textSecondary", "strokeDefault"],
>   "darkMode": "SwiftUI: theme.dark is used when the environment's colorScheme is .dark. UIKit: every token is a dynamic UIColor; assign one built with UIColor { trait in … } to vary by appearance."
> }
> ```

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

* The UI Kit is installed and you are logged in — see
  [SwiftUI getting started](https://www.cometchat.com/docs/ui-kit/ios/v6/getting-started-swiftui.md) or
  [UIKit getting started](https://www.cometchat.com/docs/ui-kit/ios/v6/getting-started-uikit.md).

***

## 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.

> [tab] SwiftUI
>
> `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.

> [tab] UIKit
>
> `CometChatUIKitTheme` carries the same tokens as `UIColor` and `UIFont` — the types UIKit
> already styles with.
>
> * `CometChatUIKitTheme.shared` — the theme every screen reads unless told otherwise.
> * 56 colour properties and 28 font properties. Each colour is a light / dark pair resolved
>   by the view's trait collection.
> * A token defined by another (`background1` is `neutral50`) follows it until you set it.
> * Every screen has a `theme` property, `CometChatUIKitTheme.shared` by default.
>
> **Precedence:** a screen's style, then the component's static default style, then the
> theme, then the Kit default.

***

## Quick Start

> [tab] SwiftUI
>
> **1. Build a theme**
>
> ```swift theme={null}
> var brandTheme: CometChatTheme {
>     var theme = CometChatTheme()
>     theme.light = .derived(primary: .indigo, isDark: false)
>     theme.dark  = .derived(primary: .indigo, isDark: true)
>     return theme
> }
> ```
>
> **2. Apply it at the root**
>
> ```swift theme={null}
> MyAppRoot()
>     .cometChatTheme(brandTheme)
> ```
>
> **3. Build and verify**
>
> Run the app and check the Kit's screens in both light and dark appearance.

> [tab] UIKit
>
> **1. Set the brand colour before showing a screen**
>
> ```swift theme={null}
> CometChatUIKitTheme.shared.setBrandColor(.systemIndigo)
> ```
>
> For example in `application(_:didFinishLaunchingWithOptions:)`, after
> `CometChatUIKit.init`.
>
> **2. 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](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/override-none.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=52632d9b876614d3adc2ff672fa4795f)

Default

![Conversations with a brand colour driving the whole derived palette](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-brand.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=1e6677b15b1b69450e7fc98b553f2099)

Brand colour

![Conversations in dark appearance](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-dark.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=abae4341b39bbf1139b28f1d2afb7c36)

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.

> [tab] SwiftUI
>
> ```swift theme={null}
> var theme = CometChatTheme()
> theme.light = .derived(primary: myBrand, isDark: false)
> theme.dark  = .derived(primary: myBrand, isDark: true)
> ```

> [tab] UIKit
>
> ```swift theme={null}
> CometChatUIKitTheme.shared.setBrandColor(UIColor(red: 0.97, green: 0.41, blue: 0.03, alpha: 1))
> ```
>
> Setting `primary` alone changes only `primary` and the tokens defined as it; the ramp is
> recomputed by `setBrandColor(_:)`.

![UIKit Conversations with the default theme](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-uikitLight.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=4a4ec38c71713e0477199800bd754e29)

UIKit — default

![UIKit Conversations after setting a brand colour on the shared theme](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-uikitBrand.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=6a70acc67abc49182bbf5553cdb11831)

UIKit — setBrandColor(\_:)

***

## Customize Common Theme Tokens

Every token stays individually settable after deriving.

> [tab] SwiftUI
>
> ```swift theme={null}
> var theme = CometChatTheme()
> theme.light = .derived(primary: .indigo, isDark: false)
> theme.light.background1 = .white
> theme.light.background2 = Color(red: 0.96, green: 0.96, blue: 0.96)
> theme.light.textPrimary = .black
> theme.light.textSecondary = .gray
> theme.light.strokeDefault = Color(red: 0.88, green: 0.88, blue: 0.88)
> ```
>
> `CometChatColorScheme` is a value: a token you set is that colour, whatever it was
> derived from.

> [tab] UIKit
>
> ```swift theme={null}
> let theme = CometChatUIKitTheme.shared
> theme.setBrandColor(.systemIndigo)
> theme.background1 = .systemBackground
> theme.background2 = .secondarySystemBackground
> theme.textPrimary = .label
> theme.textSecondary = .secondaryLabel
> theme.strokeDefault = .separator
> ```
>
> Setting a token that others are defined by moves them too: set `neutral300` and
> `background4` and `strokeDefault` follow, until you set those.

***

## 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.

> [tab] SwiftUI
>
> `theme.dark` is used when the environment's `colorScheme` is `.dark`:
>
> ```swift theme={null}
> var theme = CometChatTheme()
> theme.light = .derived(primary: Color(red: 0.41, green: 0.32, blue: 0.84), isDark: false)
> theme.dark = .derived(primary: Color(red: 0.55, green: 0.50, blue: 1.0), isDark: true)
> theme.dark.background1 = Color(red: 0.10, green: 0.10, blue: 0.10)
> theme.dark.textPrimary = .white
> ```

> [tab] UIKit
>
> Each token is a dynamic `UIColor`. Assign one that resolves per appearance:
>
> ```swift theme={null}
> CometChatUIKitTheme.shared.background1 = UIColor { trait in
>     trait.userInterfaceStyle == .dark
>         ? UIColor(red: 0.10, green: 0.10, blue: 0.10, alpha: 1)
>         : .white
> }
> ```
>
> A plain colour is used in both appearances. `setBrandColor(_:)` keeps the ramp
> appearance-aware: it mixes toward white in light and black in dark.

***

## Apply a Theme to a Specific Screen

> [tab] SwiftUI
>
> The theme is scoped to the view you set it on, so a nested `.cometChatTheme(_:)` wins
> for its subtree:
>
> ```swift theme={null}
> struct RootView: View {
>     var body: some View {
>         TabView {
>             CometChatConversations()
>                 .tabItem { Label("Chats", systemImage: "message") }
>             CometChatUsers()
>                 .cometChatTheme(.brand)
>                 .tabItem { Label("Users", systemImage: "person.2") }
>         }
>         .cometChatTheme(brandTheme)
>     }
> }
> ```

> [tab] UIKit
>
> Give one screen its own `CometChatUIKitTheme`:
>
> ```swift theme={null}
> let support = CometChatUIKitTheme()
> support.setBrandColor(.systemTeal)
>
> let conversations = CometChatConversations()
> conversations.theme = support
> ```
>
> Other screens keep reading `CometChatUIKitTheme.shared`.

***

## Typography

28 tokens: each level in bold, medium and regular, in the system font.

| Level | Size at the default text size | Weights |
| - | - | - |
| `title…` | 32 pt | bold / medium / regular |
| `heading1…` | 24 pt | bold / medium / regular |
| `heading2…` | 20 pt | bold / medium / regular |
| `heading3…` | 18 pt | bold / medium / regular |
| `heading4…` | 16 pt | bold / medium / regular |
| `body…` | 14 pt | bold / medium / regular |
| `caption1…` | 12 pt | bold / medium / regular |
| `caption2…` | 10 pt | bold / medium / regular |
| `button…` | 14 pt | bold / medium / regular |
| `link…` | 14 pt | regular |

> [tab] SwiftUI
>
> Build the whole scale in your font family, or replace one token:
>
> ```swift theme={null}
> var theme = CometChatTheme()
> theme.typography = .derived(family: "Avenir Next")
> theme.typography.heading4Bold = .system(size: 17, weight: .heavy)
> ```

> [tab] UIKit
>
> ```swift theme={null}
> let theme = CometChatUIKitTheme.shared
> theme.bodyRegular = UIFontMetrics(forTextStyle: .body)
>     .scaledFont(for: UIFont(name: "AvenirNext-Regular", size: 14) ?? .systemFont(ofSize: 14))
> theme.heading4Bold = .systemFont(ofSize: 17, weight: .heavy)
> ```
>
> A font you set is used as given — scale it with `UIFontMetrics` to keep Dynamic Type.

> [!NOTE]
>
> 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](https://www.cometchat.com/docs/ui-kit/ios/v6/color-resources.md) lists all 56
with their light and dark values.

| Token | Used for |
| - | - |
| `primary` | buttons, highlights, outgoing bubbles, interactive elements |
| `background1` | main surface |
| `background2` | secondary surface |
| `background3` | tertiary surface — the message list, search fields |
| `background4` | quaternary surface |
| `textPrimary` | primary text |
| `textSecondary` | secondary and subtitle text |
| `textTertiary` | hints and placeholders |
| `textHighlight` | highlighted and linked text |
| `strokeDefault` | default borders and dividers |
| `strokeLight` | light borders |
| `strokeDark` | dark borders |
| `success` | success indicators |
| `error` | errors, destructive actions |
| `warning` | warnings, self-mentions |
| `info` | informational indicators, link buttons |

## 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

> [card] [Color Resources](https://www.cometchat.com/docs/ui-kit/ios/v6/color-resources.md)
>
> Every colour token with its light and dark value.

> [card] [Component Styling](https://www.cometchat.com/docs/ui-kit/ios/v6/component-styling.md)
>
> Style one component without changing the theme.

> [card] [Message Bubble Styling](https://www.cometchat.com/docs/ui-kit/ios/v6/message-bubble-styling.md)
>
> Incoming, outgoing and per-kind bubble styles.

> [card] [Localize](https://www.cometchat.com/docs/ui-kit/ios/v6/localize.md)
>
> Languages and date formats.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.