Skip to main content

Custom UI

There are two ways to customize VTO:

  1. Theme Designer: change colors, fonts, text and screens of the built-in UI in PulpoAR Studio. No code needed. See Theme Designer.
  2. Custom UI: build your own UI and run only the PulpoAR try-on engine. This page covers this option.

In custom mode (?custom=true), the plugin renders only the camera or photo with makeup applied. You build every control (shade swatches, camera buttons, model selection) and drive the plugin through the JavaScript SDK.

Step 1: Start the plugin in custom mode​

Create an index.html file:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Custom Plugin</title>
<style>
body { display: flex; align-items: center; justify-content: center; }
iframe { width: 480px; height: 640px; border: none; }
</style>
</head>
<body>
<iframe src="https://plugin.pulpoar.com/vto/<project-key>?custom=true" allow="camera *;"></iframe>

<script src="https://cdn.jsdelivr.net/npm/@pulpoar/plugin-sdk@latest/dist/index.iife.js"></script>
<script>
pulpoar.onReady(() => {
console.log('PulpoAR ready');
});
</script>
</body>
</html>

Open the page. The camera view should start, and PulpoAR ready should appear in the console.

Step 2: Add your own controls​

Before you start

Make sure your product variants have slugs assigned. You apply variants by slug.

This example adds camera and model buttons, plus shade swatches that apply variants:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Custom Plugin</title>
<style>
body { display: flex; align-items: center; justify-content: center; }
.plugin-container {
position: relative;
width: 480px;
height: 640px;
border-radius: 8px;
overflow: hidden;
}
.iframe { width: 100%; height: 100%; border: none; }
.controls, .variants {
position: absolute;
width: 100%;
display: flex;
justify-content: center;
gap: 10px;
}
.controls { bottom: 60px; }
.variants { bottom: 10px; }
.variant { width: 40px; height: 40px; border: none; border-radius: 4px; cursor: pointer; }
</style>
</head>
<body>
<div class="plugin-container">
<iframe class="iframe" src="https://plugin.pulpoar.com/vto/<project-key>?custom=true" allow="camera *;"></iframe>
<div class="controls">
<button onclick="turnOnCamera()">Turn on Camera</button>
<button onclick="setModel(0)">Model 1</button>
<button onclick="setModel(1)">Model 2</button>
</div>
<div class="variants">
<button class="variant" onclick="clearAppliedVariants()">✕</button>
</div>
</div>

<script src="https://cdn.jsdelivr.net/npm/@pulpoar/plugin-sdk@latest/dist/index.iife.js"></script>
<script>
// Your variants: slug from PulpoAR, a name and a color for the swatch
const productVariants = [
{ slug: '<variant-slug-1>', name: 'Ruby Red', color: 'red' },
{ slug: '<variant-slug-2>', name: 'Soft Pink', color: 'pink' },
];

// Model images (URL or base64)
const models = [
'https://example.com/model-1.webp',
'https://example.com/model-2.webp',
];

// Start on the first model with the first shade
pulpoar.onReady(() => {
pulpoar.setImageToApply(models[0]);
applyVariant(productVariants[0].slug);
});

// Render a swatch per variant
const variantsElement = document.querySelector('.variants');
productVariants.forEach((variant) => {
const swatch = document.createElement('button');
swatch.className = 'variant';
swatch.style.backgroundColor = variant.color;
swatch.setAttribute('aria-label', variant.name);
swatch.title = variant.name;
swatch.addEventListener('click', () => applyVariant(variant.slug));
variantsElement.appendChild(swatch);
});

function applyVariant(slug) {
pulpoar.applyVariants([slug], (appliedVariants) => {
console.log('Applied', appliedVariants);
});
}

function clearAppliedVariants() {
pulpoar.applyVariants([]);
}

function turnOnCamera() {
pulpoar.initCamera({ facingMode: 'user' });
}

function setModel(index) {
pulpoar.setImageToApply(models[index]);
}
</script>
</body>
</html>

Actions you'll typically use​

ActionPurpose
applyVariantsApply or clear shades
initCameraStart the camera
setCameraFeedStatusPause or resume the camera
setImageToApplyApply makeup on a photo or model image
setPathSwitch between live camera and photo modes

You can get your catalog data, including variants, products and categories, from the onReady payload or from the Partner API.

For native mobile apps, see Hybrid integration or the native SDK Try-On Kit.