Stripe | Financial Infrastructure to Grow Your Revenue

Stripe | Financial Infrastructure to Grow Your Revenue

4466 articles

Style the payment form at the checkout


Style the payment form at the checkout

Change the theme or appearance of Stripe's PaymentElement.

You can change the theme or appearance of Stripe’s PaymentElement on your checkout page, using the Appearance API.

You can set the following parameter in the Appearance API:

  • Theme : A foundational UI built by Stripe.
  • Variables : CSS definitions to apply across the theme.
  • Rules : Conditions that target individual DOM elements within iframe of the payment form.

This guide instructs you how to change the Appearance API parameters of the Stripe module by defining a custom module that overrides them.

Create a new module

Create a new module with the following directory structure. Replace Vendor with your preferred vendor name.

Inside registration.php, register your module with Magento.

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
 \Magento\Framework\Component\ComponentRegistrar::MODULE,
 'Vendor_StripeCustomizations',
 __DIR__
);

Inside the relevant part of the product, define the module and set up dependencies to make sure it loads after the Stripe module.

Inside the relevant part of the product, define the plugin:

Inside the relevant part of the product, create the plugin class:

<?php
namespace Vendor\StripeCustomizations\Plugin\Payments\Helper;

use StripeIntegration\Payments\Helper\InitParams;
use Magento\Quote\Model\Quote;
use Psr\Log\LoggerInterface;

class InitParamsPlugin
{
 /**
 * After plugin for getElementOptions method.
 *
 * @param InitParams $subject
 * @param array $result
 * @return array
 */
 public function afterGetElementOptions(InitParams $subject, $result)
 {
 $result['appearance']['variables']['colorPrimary'] = '#FF5733'; // Example: Primary color
 $result['appearance']['variables']['spacingUnit'] = '4px'; // Example: Spacing unit
 $result['appearance']['rules'] = [
 [
 'selector' => 'button',
 'style' => [
 'backgroundColor' => '#FF5733',
 'fontSize' => '16px'
 ]
 ],
 [
 'selector' => 'input',
 'style' => [
 'borderColor' => '#CCCCCC'
 ]
 ]
 ];

 return $result;
 }
}

Enable the module:

php bin/magento module:enable Vendor_StripeCustomizations
php bin/magento setup:upgrade
php bin/magento cache:clean
php bin/magento cache:flush
Last verified 2026-09-24

Is this helpful?