Customize Paypal button with HTML/CSS and Javascript

Nguyen Phong Thien
2 min readMar 18, 2021

I believe that there’re some developers who want to customize the Paypal button only using Front-end technologies. However, the options that are provided by Paypal are quite limited. Hope this article solves your problem if you’re one of those.

So, the Paypal button is basically inside an iframe, which you can’t access and do anything for its style. Therefore, my solution is to create a cover for that iframe and let the user click through it. Simple enough? See what we need to do here.

Add Paypal SDK:

<script src=”https://www.paypal.com/sdk/js?client-id=%CLIENT_ID%"></script>

Add the HTML elements

<div class=”paypal-button”>

<div id=”paypal-button-container” />

<div class=”fake-paypal-button”>My custom message</div>

</div>

And add the code to render the PayPal button

paypal.Buttons( ).render(‘#paypal-button-container’);

Now the most important part, cover the Paypal button by CSS with the fake button and let the user click through it

.paypal-button {

position: relative;

width: 300px;

height: 50px;

}

.fake-paypal-button {

position: absolute;

top: 0;

bottom: 0;

left: 0;

right: 0;

z-index: 9999;

background-color: green;

color: white;

pointer-events: none;

}

Easy enough? that’s it!!!

--

--