Skip to main content

Component styling

Library components are styled via style structs (FieldStyle, PayButtonStyle, PaymentStatusStyle, LoadingStyle, ApplePayButtonStyle). Each component takes its style struct via the style: parameter in its initializer.

Secure Fields (input fields)

Secure Fields styling is done with the FieldStyle struct. The same struct is used for SecurePanField, SecureExpiryField, SecureCvvField, and SecureFullNameField.

FieldStyle properties

PropertyTypeDefaultDescription
borderColorColor#E5E5E5Border color in the normal state.
focusedBorderColorColor#E5E5E5Border color when focused.
errorBorderColorColor#B00020Border color in the error state.
textColorColor#111111Text color.
hintColorColor#BDBDBDPlaceholder text color.
backgroundColorColor.whiteField background color.
cornerRadiusCGFloat12Corner radius in points.
verticalPaddingCGFloat14Vertical padding.
horizontalPaddingCGFloat14Horizontal padding.
fontFont.system(size: 17, weight: .regular)Text font.

A FieldStyle.default preset with all default values is available.

Example

let style = FieldStyle(
borderColor: Color(red: 0.90, green: 0.90, blue: 0.94),
focusedBorderColor: Color(red: 0.10, green: 0.47, blue: 0.91),
errorBorderColor: Color(red: 0.78, green: 0.16, blue: 0.16),
textColor: .black,
hintColor: .gray,
backgroundColor: Color(red: 0.98, green: 0.98, blue: 0.98),
cornerRadius: 14,
verticalPadding: 14,
horizontalPadding: 16,
font: .system(size: 17, weight: .medium)
)

VStack(spacing: 12) {
SecurePanField(state: panState, style: style)
SecureExpiryField(state: expiryState, style: style)
SecureCvvField(state: cvvState, style: style)
SecureFullNameField(state: nameState, style: style)
}

Styling multiple fields at once

Create a single shared FieldStyle instance and pass it to all fields:

private let sharedFieldStyle = FieldStyle(
cornerRadius: 14,
verticalPadding: 14,
horizontalPadding: 16,
font: .system(size: 17, weight: .medium)
)

SecurePanField(state: panState, style: sharedFieldStyle)
SecureExpiryField(state: expiryState, style: sharedFieldStyle)
SecureCvvField(state: cvvState, style: sharedFieldStyle)
Information

Border states (borderColor, focusedBorderColor, errorBorderColor) switch automatically based on the field's state. Priority: error > focus > normal.

SecurePayButton (payment button)

SecurePayButton styling is done with the PayButtonStyle struct.

PayButtonStyle properties

PropertyTypeDefaultDescription
backgroundColorColorgreen (#4CAF50)Background color in the active state.
disabledBackgroundColorColorlight gray (#F5F5F5)Background color in the disabled state.
textColorColor.whiteText color in the active state.
disabledTextColorColor#BDBDBDText color in the disabled state.
cornerRadiusCGFloat12Corner radius in points.
fontFont.system(size: 16, weight: .bold)Text font.
textFontNameString?nilCustom font name. When set, overrides font.
disableShimmerBoolfalseDisables the shimmer animation during processing.
shimmerBaseColorColorColor.gray.opacity(0.25)Base color of the shimmer band.
shimmerHighlightColorColorColor.white.opacity(0.55)Highlight color of the shimmer band.
processingTextString?nilCustom text shown during processing. When nil, Translation.payButtonProcessingText is used.
buttonTextString?nilCustom button text. When nil, Translation.payButtonText is used.
borderColorColor.clearBorder color.
borderWidthCGFloat0Border width in points.
paddingHorizontalCGFloat16Horizontal padding.
paddingVerticalCGFloat12Vertical padding.

A PayButtonStyle.default preset with all default values is available.

Example

SecurePayButton(
session: session,
collector: collector,
paymentParams: { /* ... */ },
onResult: { _ in },
style: PayButtonStyle(
backgroundColor: Color(red: 0.12, green: 0.53, blue: 0.90),
textColor: .white,
cornerRadius: 14,
font: .system(size: 16, weight: .semibold),
disableShimmer: false,
processingText: "Processing…",
borderColor: Color(red: 0.08, green: 0.40, blue: 0.78),
borderWidth: 1,
buttonText: "Pay"
)
)

Automatic disabled state

SecurePayButton automatically becomes disabled when:

  • the session is not initialized (session.state != .ready),
  • the card data is not valid (collector.isValid == false),
  • a payment is currently being processed.

In the disabled state, disabledBackgroundColor and disabledTextColor are used.

Animation during payment processing

After tapping the button, a shimmer animation appears over its content — a translucent band that sweeps from left to right. The animation can be disabled:

let style = PayButtonStyle(disableShimmer: true)

SecurePaymentStatusView (status banner)

SecurePaymentStatusView styling is done with the PaymentStatusStyle struct.

PaymentStatusStyle properties

PropertyTypeDefaultDescription
textColorColor?automatic per stateText color. When nil, the default color for the given state is used (green/orange/red).
backgroundColorColor?automatic per stateBackground color. When nil, the default color for the given state is used.
borderColorColor?automatic per stateBorder color. When nil, the default color for the given state is used.
borderWidthCGFloat1Border width.
cornerRadiusCGFloat8Corner radius.
paddingHorizontalCGFloat16Horizontal padding.
paddingVerticalCGFloat10Vertical padding.
textFontNameString?nilCustom font name.
textSizeCGFloat14Text size in points.

A PaymentStatusStyle.default preset is available.

Example

@StateObject private var statusState = PaymentStatusState()

var body: some View {
VStack {
SecurePaymentStatusView(
state: statusState,
style: PaymentStatusStyle(
cornerRadius: 12,
paddingHorizontal: 20,
paddingVertical: 14,
textSize: 15
)
)
}
}
Tip

The component is hidden by default (PaymentStatusState.visible == false). It appears after calling statusState.show(result: paymentResult). It hides after calling statusState.hide() or statusState.clear(). For more details on showing payment statuses, see Payment results.

ApplePayButtonStyle

SecureApplePayButton styling is described in Apple Pay — Button appearance.

LoadingStyle

Styling of the loading indicator (SecureLoadingView and .secureLoadingOverlay) is described in Loading indicator — LoadingStyle.