Skip to main content

Overview

The outer styling (any containers around fields, etc) is completely in your control. Secure Fields also generates classes along with a set of data attributes and attaches them to the outer <iframe> containers, so they can be targeted with custom CSS. Finally, an object of CSS rules can be passed to the addCardNumberField, addExpiryDateField, addSecurityCodeField and addField methods options to style elements inside the frames.
Secure Fields Anatomy
When customizing the visual appearance using theming options, please ensure the design meets accessibility standards set by the European Accessibility Act (EAA). Make sure color choices have enough contrast and text is easy to read for all users.

Usage

To customize a field, pass an Object containing some Options Any options override the defaults.

Options

Placeholder

A placeholder text for the field can be added as a string.

Pattern

A pattern the field value should match can be added as a string (regular expression). This only applies to the postal code field. Without a pattern, a postal code is valid when it has at least 5 characters. To accept shorter postal codes, set a pattern.

Max length

A maximum length for the field value can be added as a number. This only applies to the postal code field.

Styles

Each secure input is wrapped with a div, which can be targeted with custom CSS using the following selectors:
For styling the element inside the secure input, CSS rules can be added to a styles Object this way:
  • Base styles are declared by setting keys in camelCase format (PascalCase for vendor-prefixed properties) and values as strings
  • Hover, focus and other states are declared by setting keys to :[state] (for example :hover) and values as objects containing base styles
Secure Fields only allows certain CSS properties. Here’s the full list.

Logos

To show card scheme logos in the card number field, use the showSchemeIcons option. Secure Fields then shows the detected scheme, any additional schemes of a co-badged card, and optional placeholders. It updates the icons as the buyer types.
Secure Fields shows up to 3 icons inside the card number field. Each icon is 48 px wide with 4 px spacing, so make the card number input wide enough to fit them next to the card number.
To build your own logo display instead, listen to the card-details-changed event on the card number field and show the logo for its scheme. Load the logos from https://cdn.{gr4vyId}.gr4vy.app/assets/icons/card-schemes/{scheme}.svg, adding sandbox. before your Gr4vy ID in sandbox. Refer to card scheme definitions for the list of schemes and their logos.