Skip to main content

Customize

Style the card fields and update their configuration at runtime without re-rendering.

Apply styles

Pass a VaultStyles object in SecureFieldsConfig.styles. Styles are applied to all fields at render time.

SecureFieldsConfig(
brands = listOf(Brand.VISA, Brand.MASTERCARD),
fields = ...,
styles = VaultStyles(
fontSize = "16sp",
color = "#1A1A1A",
placeholderColor = "#9E9E9E",
backgroundColor = "#FFFFFF",
focus = VaultStyles(
color = "#000000",
),
invalid = VaultStyles(
color = "#D32F2F",
),
)
)

Available style properties

PropertyDescriptionExample
fontFamilyFont family name"sans-serif"
fontSizeText size — use sp to respect system font size"16sp"
lineHeightLine height"24sp"
fontWeightFont weight"400", "bold"
colorInput text color (hex)"#1A1A1A"
placeholderColorPlaceholder text color (hex)"#9E9E9E"
backgroundColorField background color (hex)"#FFFFFF"

Pseudo-class overrides

Nest a VaultStyles instance in focus, empty, valid, invalid, or placeholder to apply styles conditionally — like CSS pseudo-classes:

VaultStyles(
color = "#1A1A1A",
focus = VaultStyles(color = "#000000"),
empty = VaultStyles(placeholderColor = "#BDBDBD"),
valid = VaultStyles(color = "#1B5E20"),
invalid = VaultStyles(color = "#D32F2F"),
placeholder = VaultStyles(color = "#BDBDBD"),
)
Pseudo-classWhen it applies
focusField is focused
emptyField has no input
validField passes validation
invalidField fails validation
placeholderPlaceholder text is shown

Configure fields

Set placeholder and contentDescription per field in VaultFieldConfig:

SecureFieldsFieldsConfig(
cardNumber = VaultFieldConfig(
placeholder = "1234 5678 9012 3456",
contentDescription = "Card number",
),
expDate = VaultFieldConfig(placeholder = "MM / YY"),
cvv = VaultFieldConfig(placeholder = "CVV"),
)

Available fields

FieldRequiredDescription
cvvYesCard verification value
cardNumberNoPrimary account number
expDateNoExpiration date
holderNameNoCardholder name

cvv is the only required field. Omit the others to render a CVV-only form — for example, when the customer has a stored card and only needs to re-enter the security code.

Supported brands

Pass the brands you accept in SecureFieldsConfig.brands. The SDK uses this list to validate card numbers and filter BIN lookup results.

SecureFieldsConfig(
brands = listOf(Brand.VISA, Brand.MASTERCARD, Brand.AMEX, Brand.CB),
...
)

Available values: VISA, MASTERCARD, AMEX, CB, DISCOVER, DINERS, JCB, MAESTRO, UNIONPAY, ONEY.

If a card matches more than one of these (e.g. CB/VISA), set SecureFieldsConfig.brandSelector = true to let the cardholder choose — see Co-branded card picker.

Update configuration after render

Call setFieldConfig() to update a field's placeholder, content description, or styles without destroying and re-creating the SDK instance:

secureFields.setFieldConfig(
field = VaultFieldName.CardNumber,
config = VaultFieldConfigUpdate(
placeholder = "Enter your card number",
styles = VaultStyles(color = "#000000"),
)
)

VaultFieldName values: CardNumber, HolderName, ExpDate, Cvv.

note

setFieldConfig() updates the visual configuration only. It does not clear or reset the field value.