Styling Widget
Customizing the Swapper Finance Widget Appearance
Customizing the Widget's Appearance
Overview of the Styling System
How to Apply Styles
// In your JavaScript when configuring the widget:
const yourIntegratorId = "xxxx"; // Your actual integrator ID
const IFRAME_BASE_URI = "https://app.swapper.finance";
const iframeElement = document.getElementById("swapperFinanceWidget"); // Assuming your iframe has this ID
const swapperConfig = {
integratorId: yourIntegratorId,
styles: { // <-- Add your styles object here
themeMode: 'dark',
brandTheme: {
primaryColor: '#FF6B35', // Your primary brand color
},
componentStyles: {
backgroundColor: "#444444"
}
}
};
// Serialize the styles object as JSON to be passed via URL
const queryParams = new URLSearchParams({
integratorId: swapperConfig.integratorId,
styles: JSON.stringify(swapperConfig.styles),
}).toString();
// Set the iframe source URL
if (iframeElement) {
const iframeSrc = `${IFRAME_BASE_URI}?${queryParams}`;
iframeElement.src = iframeSrc;
console.log("Swapper Finance Widget: URL configured with query parameters.");
console.log("Full URL:", iframeSrc);
} else {
console.error("Swapper Finance Widget: Iframe element not found.");
}Style Configuration Object (SwapperStyles)
SwapperStyles)Customization Levels & Examples
1. Theme Mode (themeMode)
themeMode)2. Brand Theme (brandTheme)
brandTheme)3. Component Styles (componentStyles)
componentStyles)Style Application Hierarchy
Color Validation
Last updated