SpacingOverrides lets you override the spacing scale the Primer iOS SDK uses for padding, gaps, and layout rhythm across the prebuilt screens and the composable views. You pass it through the spacing parameter of PrimerCheckoutTheme.
Every property is optional. A nil value falls back to the internal default token, so you only set the values you want to change.
Internal
DesignTokens (auto-generated from JSON) remain the source of truth for spacing. SpacingOverrides merges your values on top of those defaults — any token you leave nil keeps its internal default.Properties
All properties areCGFloat? and measured in points. The default column shows the internal token value used when you leave the property nil.
| Property | Type | Default | Description |
|---|---|---|---|
primerSpaceXxsmall | CGFloat? | 2 | Minimal gaps, icon padding. |
primerSpaceXsmall | CGFloat? | 4 | Tight spacing, chip padding. |
primerSpaceSmall | CGFloat? | 8 | Gaps between form fields. |
primerSpaceMedium | CGFloat? | 12 | Section internal padding. |
primerSpaceLarge | CGFloat? | 16 | Container padding, major gaps. |
primerSpaceXlarge | CGFloat? | 20 | Spacing between major sections. |
primerSpaceXxlarge | CGFloat? | 24 | Largest section spacing. |
primerSpaceBase | CGFloat? | 4 | Base unit for spacing calculations. |
Initializer
Every parameter defaults tonil, so you can construct an override that touches only the tokens you care about.
Overriding spacing
Build aPrimerCheckoutTheme with a SpacingOverrides value and pass it to your checkout. The example below loosens the spacing between fields and sections while leaving everything else at the internal defaults.
primerTheme:
PrimerCheckoutSession instead. The composable views resolve the merged tokens from the session.
These tokens control the spacing used inside Primer’s own views. They do not affect the padding you add around the SDK in your own layout — use standard SwiftUI modifiers such as
.padding() for that.See also
PrimerTheme
The theme container that carries spacing and the other override groups.
Shape Tokens
Corner-radius and border-width override tokens.