7. Custom styling the Web-Components

Web-Components are the most convenient way to integrate functionalities in your application. Like any other UI elements in your application we provide simple ways to style these Web-Components so they become part of your application for a seamless user experience.

Below you will find examples in some popular frontend frameworks.

For a complete list of customizable style elements please refer to our guide JS Client Library Properties and Styling section.

React

Step 1. Install the npm package

npm install payengine

Step 2. Create CSS module file for your component (MyComponent.module.css)

/*
    MyComponent.module.css
*/

.pf-transaction-table .tabulator-col-title-holder {
    border: 1px red solid;
}

.pf-transactions-table-col-title {
    font-size: 0.8rem;
}

Step 3. Import and apply styles in your React component

/*
    MyComponent.js
*/

import { loadPlatform, payengineStyles } from "payengine";
import overrideStyle from "MyComponenet.module.css";

const MyComponent = () => {

    useEffect(() => {
        // Load Platform on first render only
        loadPlatform({
            publicKey: <your PAYENGINE_PUBLIC_KEY>,        
        }).then((pe) => {
            // Your sucess handler goes here.
        });  
    }, []);
 
    return (
    <>
    <payment-platform 
      type="boarding" 
      merchant-id="<payengine_merchant_id>" 
      hash="<HMAC_hash_of_payengine_merchant_id>"
      styleModule={{payengineStyles(overrideStyle)}}>
    </payment-platform>        
    </>
    )   
}

Vue.js

With Vue.js we have two options available and you can choose what best fits your application architecture.

Step 1. Install the npm package

npm install payengine

Step 2. Create modular <style> in your component and apply to Web-Component

Option1 - Via style module within your .vue file

/*
    MyComponent.vue
*/

<template>
<div>
    <payment-platform 
      type="boarding" 
      merchant-id="<payengine_merchant_id>" 
      hash="<HMAC_hash_of_payengine_merchant_id>">
      :styleModule="payengineStyles(payengineOverrides)"
    </payment-platform>        
</div>
</template>

<script>
import { loadPlatform, payengineStyles } from "payengine";

export default {
    name: "MyComponent",
    methods: {
        payengineStyles
    },
    created() {    
        try {
             loadPlatform({
                publicKey: <your PAYENGINE_PUBLIC_KEY>,
            });
        } catch (e) {
            // error handling
        }
    }
}

</script>

<style>
/*
    Your Vue.js component's style
*/
</style>

<style module="payengineOverrides">
.pf-transaction-table .tabulator-col-title-holder {
    border: 1px red solid;
}

.pf-transactions-table-col-title {
    font-size: 0.8rem;
}
</style>

Option 2 - CSS module file for your component (MyComponent.module.css)

  1. Create MyComponent.module.css

/*
    MyComponent.module.css
*/

.pf-transaction-table .tabulator-col-title-holder {
    border: 1px red solid;
}

.pf-transactions-table-col-title {
    font-size: 0.8rem;
}

2. Create MyComponent.vue

/*
    MyComponent.vue
*/

<template>
<div>
    <payment-platform 
      type="boarding" 
      merchant-id="<payengine_merchant_id>" 
      hash="<HMAC_hash_of_payengine_merchant_id>">
      :styleModule="payengineStyles(payengineOverrides)"
    </payment-platform>        
</div>
</template>

<script>
import { loadPlatform, payengineStyles } from "payengine";
import payengineOverrides from "MyComponenet.module.css";

export default {
    name: "MyComponent",
    methods: {
        payengineStyles
    },
    created() {    
        try {
             loadPlatform({
                publicKey: <your PAYENGINE_PUBLIC_KEY>,
            });
        } catch (e) {
            // error handling
        }
    }
}

</script>

<style>
/*
    Your Vue.js component's style
*/
</style>

Last updated