Skip to main content

Table of Contents

  1. Overview
  2. How Styling Works
  3. Card Form Styling
  4. Field Variants
  5. Card Icon Alignment
  6. Layout Presets
  7. Card Payment Button Styling
  8. Generic Redirect Button Styling
  9. Stored Instruments Styling
  10. Apple Pay Button Styling
  11. Translations & Labels
  12. Using with SwiftUI
  13. Full Example: Themed Checkout
  14. Style Properties Reference

Overview

The Payrails iOS SDK ships with sensible default styles for every UI component. You can override any property you want — only the values you provide will replace the defaults, everything else stays intact. Key components you can style:

How Styling Works

The SDK uses a merge-over-defaults pattern:
  1. Every style struct has a .defaultStyle preset with production-ready defaults.
  2. You create a style struct and set only the properties you want to change — leave everything else nil.
  3. The SDK automatically merges your customizations over the defaults.
This means you never need to provide a complete style — just your overrides.

Card Form Styling

The card form is created via Payrails.createCardForm(config:). All visual customization goes into CardFormConfig.styles, which is a CardFormStylesConfig.

Quick Start


Wrapper Style

CardWrapperStyle controls the outer container that wraps all fields.
Example — card-like wrapper with shadow feel:

Input Field Styles

CardFieldSpecificStyles lets you style text fields for each state: Each state is a CardStyle (alias for Style) with these properties:
Example — modern rounded fields:
You only need to set properties that differ from the base state. For example, if the focus state should only change the border color, just set borderColor in focus.

Per-Field Overrides

Need a specific field to look different? Use inputFieldStyles to target individual fields by type:
Available field types:
Per-field styles are merged over allInputFieldStyles, so you only need to specify the differences.

Label Styles

Customize the label above each field:

Error Text Style

Control how validation error messages look below fields:

Spacing

Fine-tune the spacing between fields and sections:

Field Insets

fieldInsets controls the spacing between a field and its container edge — independent of padding, which controls text inset inside the field.
Use the convenience method .fieldInsets(top:left:bottom:right:) — defaults are (0, 6, 0, 6):
Only specify the sides you want to change:
Per-field overrides work via inputFieldStyles:
When an explicit width is set, fieldInsets is ignored—the field uses a fixed-width constraint instead.

Field Variants

Choose between two visual styles for input fields:
You can further customize each variant using CardFieldSpecificStyles as described above.

Card Icon Alignment

Display the detected card brand icon (Visa, Mastercard, etc.) inside the card number field:

Layout Presets

Control the arrangement of fields using built-in presets or a custom layout:

Built-in Presets

Combined Expiry Date Field

Replace separate month/year fields with a single MM/YY field:

Custom Layout

Define exactly which fields appear on each row:
Custom layouts must include .CARD_NUMBER, .CVV, and expiry fields (either .EXPIRATION_DATE or both .EXPIRATION_MONTH / .EXPIRATION_YEAR). If the layout is invalid, the SDK falls back to the standard preset.

Card Payment Button Styling

Created via session.createCardPaymentButton(buttonStyle:translations:).

Properties

Examples

The button automatically shows a loading spinner during payment processing — no extra code needed.

Generic Redirect Button Styling

For redirect-based payment methods (iDEAL, Sofort, Klarna, etc.). Uses the same CardButtonStyle:

Stored Instruments Styling

When returning customers have saved cards or PayPal accounts, the StoredInstruments view displays them as a selectable list.

List Style

Pay Button Style

Delete Button Style

Update Button Style

Full Example


Apple Pay Button Styling

Apple restricts customization of the Apple Pay button to its own set of styles and types:
You cannot apply custom fonts, colors, or corner radii to the Apple Pay button — Apple enforces its Human Interface Guidelines.

Translations & Labels

Card Form Translations

Override placeholder text, labels, and error messages:

Button Translations

Stored Instruments Translations


Using with SwiftUI

The SDK’s UI components are built with UIKit. To embed them in SwiftUI, use UIViewRepresentable:

Full Example: Themed Checkout

Here’s a complete example that demonstrates a dark-themed, brand-customized checkout:

Style Properties Reference

CardStyle (alias: Style)

CardFieldSpecificStyles

CardButtonStyle

CardWrapperStyle

CardFormStylesConfig

StoredInstrumentsStyle

StoredInstrumentButtonStyle

DeleteButtonStyle

UpdateButtonStyle


Need help? Check the SDK API Reference or the Troubleshooting Guide for common issues.
Last modified on September 30, 2026