Skip to content

Customization

Appearance config

Pass an appearance object when initializing the widget to customize its look:

const widget = new ElasticPayCardWidget("card-widget", {
apiUrl: "https://staging-api.elasticpay.co",
publishableKey: "pk_sandbox_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
clientSecret: "pi_0abc123_secret_xyz987",
appearance: {
variables: {
colorPrimary: "#2563eb",
colorBackground: "#ffffff",
colorText: "#111827",
colorDanger: "#dc2626",
fontFamily: "Archivo, sans-serif",
fontSize: "16px",
labelFontSize: "14px",
inputFontSize: "16px",
borderRadius: "6px",
},
},
});

CSS variables reference

VariableDefaultDescription
colorPrimary#ec3013Button and focus ring color
colorBackground#ffffffInput background color
colorText#201e1dInput and label text color
colorDanger#ae1800Error and invalid state color
colorSuccess#16a34aSuccess state color (direct debit widget)
fontFamilyinheritFont family for all widget text. Defaults to inherit, so the widget adopts your page’s font.
fontSize16pxBase font size
labelFontSize14pxLabel font size
inputFontSize16pxInput field font size
borderRadius8pxBorder radius for inputs and buttons

The widget ships no web font of its own and requests no font file, so embedding it adds zero font requests to your page. By default it inherits your page’s typography; set fontFamily only if you want it to differ from the surrounding page.

CSS class overrides

For deeper customization, target these stable class names:

ClassElement
.elasticpay-card-widgetRoot container
.elasticpay-card-widget__inputCard input fields
.elasticpay-card-widget__input--validInput in valid state
.elasticpay-card-widget__input--invalidInput in invalid state
.elasticpay-card-widget__submitSubmit button
.elasticpay-card-widget__status--successSuccess message
.elasticpay-card-widget__status--errorError message

Example:

.elasticpay-card-widget__input {
border: 1px solid #d1d5db;
padding: 10px 12px;
}
.elasticpay-card-widget__input--invalid {
border-color: #dc2626;
}
.elasticpay-card-widget__submit {
background-color: #2563eb;
font-weight: 600;
}

Hide the submit button

Set showSubmitButton: false to hide the built-in submit button and trigger tokenization manually:

const widget = new ElasticPayCardWidget("card-widget", {
apiUrl: "https://staging-api.elasticpay.co",
publishableKey: "pk_sandbox_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
clientSecret: "pi_0abc123_secret_xyz987",
showSubmitButton: false,
});
document.getElementById("pay-button")?.addEventListener("click", async () => {
await widget.tokenize();
});

Use this when the submit button is outside the widget container, or when you need to validate other form fields before triggering payment.