10. Theme and texts
The cashier takes its look from three places. A later source wins over an earlier one, key by key.
| Source | Applies | Wins over |
|---|---|---|
| Built-in defaults | always | nothing |
| The server theme of the cashier session | after the session loads | the defaults |
| Your CashierTheme values that are not nil | from the start | the server theme and the defaults |
| Your roleColors and cornerRadius | from the start | the 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)| Value | Accepts | Notes |
|---|---|---|
| brandColorLight, brandColorDark | Hex text with # and 3, 4, 6 or 8 hex digits | The cashier builds its whole palette from the brand colour of the appearance. CashierTheme(brand:brandText:) gives one colour for both appearances |
| brandTextColorLight, brandTextColorDark | Hex text | The text colour on the brand colour |
| fontName | The family name of a font your app has registered | The 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, .system | With .system the cashier reads the device setting when the session starts and keeps it while it is open |
| fieldLabelStyle | .noLabel, .topLabel, .floatingLabel | |
| roleColors | A colour per role, such as .accent, .accentPressed, .primaryText, .secondaryText, .screenBackground, .sheetSurface, .dialogSurface, .fieldBackground | A role you set replaces the palette value of that role |
| cornerRadius | A number | Replaces 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)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))
}
}| Use | Gives | Follows Dynamic Type |
|---|---|---|
| .cashierFont(_:) (recommended) | The font, the letter spacing and the line height of the style | Yes, with the system font and with a font your app registered |
| theme.font(_:) | A Font only | Only with a font your app registered; the system font keeps the default size |
Updated about 8 hours ago