Themed form styling
Last updated: December 21, 2022
If you want to customize your forms beyond what is supported by the default integration, you can apply a theme using the Theme
object.



When instantiating a new Theme
object, you must supply the following fields at a minimum:
accentColor
textColor
errorColor
backgroundColor
fieldBackgroundColor
enabledButtonColor
disabledButtonColor
You can then optionally provide additional values to customize other elements including button styling, custom placeholder and error text, and field input controls.
Dynamic font sizing based on the user's device is built into the Theme
object.
1// Create a color object with generic colors which will be used on all screens2private val paymentFormThemeColors = PaymentFormThemeColors(3accentColor = 0XFF00CC2D,4textColor = 0XFFB1B1B1,5errorColor = 0XFFFF0000,6backgroundColor = 0xFF17201E,7fieldBackgroundColor = 0XFF24302D,8enabledButtonColor = 0xFFFFFFFF,9disabledButtonColor = 0XFF00330010)1112// Customize card number component13private val cardNumber = PaymentFormComponentBuilder()14.setPaymentFormField(PaymentFormComponentField.CardNumber)15.setTitleTextId(R.string.cko_card_number_title)16.setSubTitleText("Card number is required")17.build()1819// Customize address line 1 component20private val addressLineOne = PaymentFormComponentBuilder()21.setPaymentFormField(PaymentFormComponentField.AddressLineOne)22.setTitleTextId(R.string.cko_billing_form_input_field_address_line_one)23.setSubTitleText("Eg. street address, apartment number")24.setInfoTextId(R.string.cko_input_field_optional_info)25.setIsFieldOptional(true)26.setIsFieldHidden(false)27.build()2829// Customize address line 2 component30private val addressLineTwo = PaymentFormComponentBuilder()31.setPaymentFormField(PaymentFormComponentField.AddressLineTwo)32.setIsFieldHidden(true)33.build()3435// Customize summary button36private val addBillingSummaryButton = PaymentFormComponentBuilder()37.setPaymentFormField(PaymentFormComponentField.AddBillingSummaryButton)38.setIsFieldOptional(false)39.setTitleText("Add billing address")40.build()4142// Customize billing summary button43private val editBillingSummaryButton = PaymentFormComponentBuilder()44.setPaymentFormField(PaymentFormComponentField.EditBillingSummaryButton)45.setTitleText("Edit billing address")46.build()4748// Create a payment form theme49fun providePaymentFormTheme(): PaymentFormTheme {50return PaymentFormTheme(51paymentFormThemeColors = paymentFormThemeColors,52/**53* option 1: Use combination of default and custom components54*/55paymentFormComponents = DefaultPaymentFormTheme.providePaymentFormComponents56cardNumber = cardNumber,57addressLineOne = addressLineOne,58addressLineTwo = addressLineTwo,59addBillingSummaryButton = addBillingSummaryButton,60editBillingSummaryButton = editBillingSummaryButton61),62/**63* option 2: Use default components64* paymentFormComponents = DefaultPaymentFormTheme.provideComponents()65*/66paymentFormShape = PaymentFormShape(67inputFieldShape = Shape.RoundCorner,68addressSummaryShape = Shape.Rectangle, buttonShape = Shape.Circle69),70paymentFormCornerRadius = PaymentFormCornerRadius(71inputFieldCornerRadius = CornerRadius(INPUT_FIELD_CORNER_RADIUS),72addressSummaryCornerRadius = CornerRadius(INPUT_FIELD_CORNER_RADIUS)73)74)75}