Table of Contents
- Overview
- How Styling Works
- Card Form Styling
- Field Variants
- Card Icon Alignment
- Layout Presets
- Card Payment Button Styling
- Generic Redirect Button Styling
- Stored Instruments Styling
- Apple Pay Button Styling
- Translations & Labels
- Using with SwiftUI
- Full Example: Themed Checkout
- 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:- Every style struct has a
.defaultStylepreset with production-ready defaults. - You create a style struct and set only the properties you want to change — leave everything else
nil. - The SDK automatically merges your customizations over the defaults.
Card Form Styling
The card form is created viaPayrails.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.
Input Field Styles
CardFieldSpecificStyles lets you style text fields for each state:
Each state is a
CardStyle (alias for Style) with these properties:
Per-Field Overrides
Need a specific field to look different? UseinputFieldStyles to target individual fields by type:
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.
.fieldInsets(top:left:bottom:right:) — defaults are (0, 6, 0, 6):
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: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 viasession.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 sameCardButtonStyle:
Stored Instruments Styling
When returning customers have saved cards or PayPal accounts, theStoredInstruments 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, useUIViewRepresentable:
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.