Skip to main content
Primer Checkout iOS SDK is currently in beta (v3.0.0-beta.8). The API is subject to change before the stable release.
PrimerCheckoutTheme is the single container for design-token overrides. Pass it to the entry-point APIs to restyle the checkout UI without replacing Primer’s internal token system. Internally, the SDK ships auto-generated DesignTokens that remain the source of truth, with a light and a dark set of defaults. When you supply a PrimerCheckoutTheme, the SDK merges your overrides on top of those defaults, and any nil value falls back to the internal default. Colors are the exception: colors applies in light mode only, and dark mode reads darkColors alone. A color you leave out of darkColors uses Primer’s dark default, not the matching colors value. To change a color in both modes, set it in both groups. radius, spacing, sizes, typography, and width apply in both modes. You only set the tokens you want to change.
Every override property is optional. A PrimerCheckoutTheme() with no arguments applies the SDK’s default appearance, so you can start from the defaults and override one group, or one token, at a time.

Declaration

Initializer

Parameters

A NaN or infinite radius, spacing, size, width, or typography number is ignored with a warning, and that token keeps its default.

Properties

PrimerCheckoutTheme is Equatable and exposes one immutable property per initializer parameter. Each is the optional value you passed to the initializer.

Token groups

A theme is made up of six override groups. ColorOverrides is used twice, for colors (light mode) and darkColors (dark mode). Each group is its own optional struct whose properties are all optional, so you only specify the tokens you want to change. The four documentation pages below cover the full property list, types, and defaults for every group.
The Shape tokens page documents three groups together: RadiusOverrides, SizeOverrides, and WidthOverrides.

Applying a theme

PrimerCheckoutTheme is accepted by all three entry points. The managed view and the UIKit presenter take it as primerTheme; the session takes it as theme. The .primerCheckoutSession(_:theme:onCompletion:) modifier also takes an optional theme. When you pass one, it replaces the session’s theme and applies again each time the value changes, so you can switch appearance at runtime.

With the managed view

With a custom layout

Theme example

Build a theme by composing the override groups. Each group only sets the tokens you care about; everything else inherits the SDK defaults.
Start small. Override primerColorBrand alone and Primer’s default tokens fill in the rest of the palette. Focus borders, spinners, and selected borders follow your brand color unless you set them. If your app supports dark mode, set primerColorBrand in darkColors too. Then add more tokens as your branding requires.

See also

Color tokens

Override brand, background, text, border, and icon colors for light and dark mode.

Typography tokens

Customize title and body text styles.

Spacing tokens

Tune padding and margin values.

Shape tokens

Radius, size, and border-width overrides.