Skip to Content
Docs

Style the card fields

Set the card inputs' colors, border, and font with fieldStyle, and their size and place in your layout with style.

Each card field component, and the saved card's CVV field, takes two style props. fieldStyle styles the native input's colors, border, and font. style lays the component out like any other React Native view. The drop-in's appearance.fieldStyle takes the same PayFieldStyle object for its card form.

<PayCardNumberField
  fields={fields}
  fieldStyle={{ borderColor: '#D9DFDB', focusedBorderColor: '#0D6B57', cornerRadius: 8 }}
  style={{ height: 52 }}
/>

Props

fieldStyle is a PayFieldStyle. Anything you leave out keeps the SDK's default look.

PropTypeRequiredDescription
textColorColorValueNoThe text's color.
placeholderColorColorValueNoThe placeholder's color.
invalidColorColorValueNoThe text's color while the value is invalid, and on iOS the border's too.
backgroundColorColorValueNoThe input's background.
borderColorColorValueNoThe border's color.
focusedBorderColorColorValueNoThe border's color while the input has focus.
borderWidthnumberNoThe border's width, in points (dp on Android).
cornerRadiusnumberNoThe corners' radius, in points (dp on Android).
fontSizenumberNoThe text's size, in points (sp on Android). It still follows the customer's text size setting.

The colors stay the same in light and dark mode. To follow dark mode, pick them with React Native's useColorScheme(). The inputs restyle when fieldStyle changes.

Layout

style takes a View style, for example width, flex, or margin. A field is 48 high unless you set its height.

Example

import { StyleSheet, useColorScheme, View } from 'react-native'
import {
  PayCardNumberField,
  PayCvcField,
  PayExpiryField,
  type PayCardFields,
  type PayFieldStyle,
} from '@pay-com/react-native'

const light: PayFieldStyle = {
  textColor: '#1B1F1D',
  placeholderColor: '#6B736F',
  invalidColor: '#C0392B',
  backgroundColor: '#FFFFFF',
  borderColor: '#D9DFDB',
  focusedBorderColor: '#0D6B57',
  borderWidth: 1,
  cornerRadius: 8,
  fontSize: 16,
}

const dark: PayFieldStyle = {
  ...light,
  textColor: '#F4F6F5',
  placeholderColor: '#9AA39F',
  backgroundColor: '#1C1F1E',
  borderColor: '#3A403D',
  focusedBorderColor: '#4FC3A1',
}

export function StyledCardFields({ fields }: { fields: PayCardFields }) {
  const fieldStyle = useColorScheme() === 'dark' ? dark : light
  return (
    <View style={styles.form}>
      <PayCardNumberField fields={fields} fieldStyle={fieldStyle} />
      <View style={styles.row}>
        <PayExpiryField fields={fields} fieldStyle={fieldStyle} style={styles.half} />
        <PayCvcField fields={fields} fieldStyle={fieldStyle} style={styles.half} />
      </View>
    </View>
  )
}

const styles = StyleSheet.create({
  form: { gap: 12 },
  row: { flexDirection: 'row', gap: 12 },
  half: { flex: 1 },
})

Next steps

Was this page helpful?