10. Theme and texts

The cashier takes its look from three places. A later source wins over an earlier one, key by key.

SourceAppliesWins over
Built-in defaultsalwaysnothing
The server theme of the cashier sessionafter the session loadsthe defaults
Your CashierTheme values that are not nilfrom the startthe server theme and the defaults
Your roleColors and cornerRadiusfrom the startthe palette colour of that role and the button-shape radius

The theme set for the merchant on the Praxis side applies on its own: the brand colours, the brand text colours, the font, the button shape, the appearance and the field label style. Settings that exist only for the web cashier, such as custom CSS, are ignored. The loading screen, shown before the server theme arrives, uses the defaults with your values applied.

let theme = CashierTheme(
    brandColorLight: "#0F768A",
    brandColorDark: "#0F758A",
    fontName: "Lora",
    buttonShape: .pill,
    appearance: .system,
    roleColors: [.accent: .indigo],
    cornerRadius: 12
)
let configuration = CashierConfiguration(theme: theme)
ValueAcceptsNotes
brandColorLight, brandColorDarkHex text with # and 3, 4, 6 or 8 hex digitsThe cashier builds its whole palette from the brand colour of the appearance. CashierTheme(brand:brandText:) gives one colour for both appearances
brandTextColorLight, brandTextColorDarkHex textThe text colour on the brand colour
fontNameThe family name of a font your app has registeredThe SDK never downloads fonts. A font the app does not have falls back to a system font of the same kind. nil or "default" uses the system font
buttonShape.rounded, .sharp, .pill
appearance.light, .dark, .systemWith .system the cashier reads the device setting when the session starts and keeps it while it is open
fieldLabelStyle.noLabel, .topLabel, .floatingLabel
roleColorsA colour per role, such as .accent, .accentPressed, .primaryText, .secondaryText, .screenBackground, .sheetSurface, .dialogSurface, .fieldBackgroundA role you set replaces the palette value of that role
cornerRadiusA numberReplaces the radius the button shape gives
  • Spacing and the type sizes cannot be changed.
  • A value the cashier cannot use, such as a hex colour that is not valid, is ignored and reported once with the event configuration_value_ignored, whose ignoredName names the field.

Texts

Every text the cashier shows comes from the server texts. Replace any of them with CashierTexts; for texts per language use CashierTexts(byLanguage:). Your texts for the exact session language win first, then your texts for every language, then the server texts. An unknown key is ignored and reported once with configuration_value_ignored.

let texts = CashierTexts([.pay: "Pay now"])
let configuration = CashierConfiguration(texts: texts)
🚧

Important

Never put card data, customer data or text from the server into your texts.

The theme for your own views

Inside the cashier, your views (slot content or your own layout) can draw with the same theme. Outside a cashier scope it holds the default theme.

struct LoyaltyHint: View {
    @Environment(\.cashierResolvedTheme) private var theme

    var body: some View {
        Text("You earn points with this deposit")
            .cashierFont(.caption)
            .foregroundStyle(theme.color(.secondaryText))
            .padding(theme.spacing(.s12))
    }
}
UseGivesFollows Dynamic Type
.cashierFont(_:) (recommended)The font, the letter spacing and the line height of the styleYes, with the system font and with a font your app registered
theme.font(_:)A Font onlyOnly with a font your app registered; the system font keeps the default size

Did this page help you?