đšStyling Stripe Card Elements
The Stripe Payment Gateway provides its own iframe to accept Card Details securely so direct styling isn't possible. Instead use JavaScript.
Introduction
The Stripe Payment Gateway provides its own iframe to accept Card Details securely so it's not possible to have full access to the HTML structure so you can apply your own styles. Instead, you can use JavaScript to pass your styles safely to Stripe.
This method will work on any kind of Payment Form which uses Stripe. This includes:
Basic Payment Form
Checkout
Subscription Sign Up
Setting Styles
Setting up the JavaScript Variable
Styles are passed securely to Stripe using JavaScript, rather than your traditional method of applying styles directly with a CSS file.
To do this, create a global JavaScript variable stripe_style
at the top of your Form Layout or Page. Its value should be an object like the following:
Available Selectors and CSS properties
As in the example above- the stripe_style
variable is passed a JavaScript object.
You can see Stripe's full definition of how this object should be structured using their documentation here: https://stripe.com/docs/js/appendix/style. The first set of keys e.g. base represents a "variant" or state the elements might be in. Nested within this, certain allowed CSS properties may be set.
Renaming the Classes - Advanced
You can ask Stripe to rename some of the available classes by redefining the classes
object. To do this in Siteglide, create a global variable stripe_classes
:
Any styles you set in the stripe_styles
object to base will still apply after changing the class, unless you specifically override them.
You can see a full reference for the available properties for this object in the Stripe documentation here: https://stripe.com/docs/js/elements_object/create_element?type=card#elements_create-options-classes
Last updated