Style the drop-in
Set the drop-in's colors for light and dark mode, its corners, borders, and fonts, its Pay button, its method rows, and its card fields.
PayDropInAppearance sets how the drop-in looks. By default, the sheet uses Material 3 with a color scheme that follows light and dark mode, applies your app theme's colorPrimary when set, and renders radio-button list items, outlined card fields, and a filled Pay button. Method rows show Pay.com's logos. Change only what you need, pass your Compose app's color schemes, or start from PayDropInAppearance.Web, the look of Universal checkout in Pay.com.js.
Pass it as the drop-in's appearance. Its texts are in PayDropInStrings.
val appearance = PayDropInAppearance(cornerRadius = 8.dp, rowStyle = PayDropInAppearance.RowStyle.CHECKMARK)
val dropIn = PayDropIn(checkout, PayDropIn.Configuration(appearance = appearance))Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
colorsLight | PayDropInColors | No | The colors in light mode. See PayDropInColors. Default: PayDropInColors(), all from the Material 3 scheme. |
colorsDark | PayDropInColors | No | The colors in dark mode. Default: PayDropInColors(). |
colorMode | PayDropInAppearance.ColorMode | No | SYSTEM follows the device's dark theme setting. LIGHT and DARK fix the mode. Default: SYSTEM. |
dynamicColor | Boolean | No | On Android 12 and later, takes the colors you leave null from the wallpaper (Material You), instead of the baseline scheme and your colorPrimary. Default: false. |
cornerRadius | Dp? | No | The corner radius of the method lists and the save-card switch. Default: null, for Material 3's large shape (16 dp). |
borderWidth | Dp | No | A border around each list, in the separator color. Default: 0.dp, no border. |
elevation | Dp | No | A shadow under each list. Default: 0.dp, no shadow. |
fontFamily | FontFamily? | No | The font of every text in the sheet, the card fields included. Default: null, the system font. |
fontScale | Float | No | Multiplies every text size. The device's font size setting still applies on top. Default: 1f. |
primaryButton | PayDropInPrimaryButton | No | The Pay button. See PayDropInPrimaryButton. Default: PayDropInPrimaryButton(). |
rowStyle | PayDropInAppearance.RowStyle | No | How the selected method is marked (RADIO for a radio button on every row, or CHECKMARK for a check mark on the selected row only). Default: RADIO. |
methodIcons | Map<String, Int> | No | Drawable resource IDs for the method rows, by payment method type, for example your own artwork for paypal. They're drawn at 24 dp, in their own colors. Rows without one show Pay.com's logo for the method, or its monogram. Default: none. |
fieldStyle | PayFieldStyle? | No | The card fields' style. See Style the card fields. fontFamily applies to it when its textStyle sets no font. Default: null, for Material 3 outlined fields in the sheet's colors. |
PayDropInColors
The sheet's colors for one mode. Each is an optional Color?, and one you leave null comes from the Material 3 scheme's role below. PayDropInColors.from(scheme) takes every color from a Compose ColorScheme, with surface from its surfaceContainerHighest.
| Parameter | Default | Web | What it colors |
|---|---|---|---|
primary | Your theme's colorPrimary, else primary | #1E1E1E | The selection, the Pay button, the save-card switch when it's on, Edit and Done, and a focused field's outline, label, and cursor. |
onPrimary | onPrimary, or near-black or white on your own primary | #FFFFFF | The Pay button's text and spinner, and the switch's thumb when it's on. |
background | surfaceContainerLow | #FFFFFF | The sheet, behind the lists and the card fields. |
surface | surfaceContainerHigh | #FFFFFF | The method lists and the save-card switch's row. Not the card fields, which are outlined on background. |
text | onSurface | #1E1E1E | The title, the close button, the rows' titles, what's typed in the fields, the switch's label, and the failure message. |
secondaryText | onSurfaceVariant | #6B6B6B | The section headers, subtitles, the Default badge, "or", unselected radio buttons, the fields' labels and placeholders, and the spinner on a row that's being removed. |
separator | outlineVariant | #D5D5D5 | The lines between rows and beside "or", the lists' borders, and the field outlines. |
error | error | #D9372D | The errors under the fields, invalid fields, the failure message's icon and tinted background, and the remove buttons. |
PayDropInPrimaryButton
The Pay button. The Google Pay button takes its height and corners too.
| Parameter | Type | Required | Description |
|---|---|---|---|
backgroundColor | Color? | No | The button's color. Default: null, for primary. |
textColor | Color? | No | Its text and spinner. Default: null, for onPrimary. |
cornerRadius | Dp? | No | Its corners. Default: null, fully rounded as Material 3 buttons are. |
borderColor | Color? | No | A border, drawn when borderWidth is more than 0. Default: null. |
borderWidth | Dp | No | The border's width. Default: 0.dp. |
height | Dp | No | Its minimum height. Default: 56.dp. |
PayDropInAppearance.Web
Matches the appearance of Universal checkout in Pay.com.js with a white surface, bordered lists, 8 dp corners, and a near-black 48 dp Pay button. It's light only. Its card fields have a style of their own, with a #6663D8 outline when focused, so the colors don't reach them. To change them, set fieldStyle. Change any part of the look with copy.
Material 3's default look, and PayDropInAppearance.Web:
Example
In a Compose app, give the sheet your theme's colors and font:
val appearance = PayDropInAppearance(
colorsLight = PayDropInColors.from(shopLightColorScheme),
colorsDark = PayDropInColors.from(shopDarkColorScheme),
fontFamily = FontFamily(Font(R.font.inter_regular), Font(R.font.inter_medium, FontWeight.Medium)),
primaryButton = PayDropInPrimaryButton(cornerRadius = 12.dp),
methodIcons = mapOf("paypal" to R.drawable.ic_paypal),
)
val dropIn = PayDropIn(checkout, PayDropIn.Configuration(appearance = appearance))Or start from the web look:
val appearance = PayDropInAppearance.Web.copy(fontFamily = FontFamily(Font(R.font.inter_regular)))Next steps
- Present the drop-in: The sheet's other options.
- Change the drop-in's text: Translate the sheet, or change its wording.
- Style the card fields: The card fields' style.