Add a virtual try-on button to any product page in one line of HTML. Customers upload a photo and see themselves wearing your product.
Platform-specific setup guides
Paste one <script> tag on your product page. The SDK auto-detects your product image and injects a “Try it on” button beneath it.
<script
src="https://www.getonfitt.com/api/sdk"
data-api-key="YOUR_API_KEY">
</script>YOUR_API_KEY with your API key from the dashboard.<head> to pre-warm the connection and reduce button load time.<link rel="preconnect" href="https://getonfitt.com">The SDK resolves the clothing item to send to the AI in this order of priority:
data-clothing-urlsdata-product-images (CSS selector for <img> tags)Multi-image gallery (AI picks the best angle for best results):
<script
src="https://www.getonfitt.com/api/sdk"
data-api-key="sk_live_..."
data-product-images=".product-gallery img">
</script>Explicit URL list (JSON array):
data-clothing-urls='["https://yourstore.com/jacket-front.jpg","https://yourstore.com/jacket-side.jpg"]'Customize the injected button with data-* attributes or via the Dashboard's Customize panel. Script-tag attributes always take precedence over dashboard settings.
Four built-in themes, or go fully custom with your own hex.
purpledarklightcustom| Attribute | Type | Default | Description |
|---|---|---|---|
data-api-key | string | — | Your OnFitt API key. Required. |
data-theme | purple | dark | light | custom | purple | Built-in colour preset. Use custom to set your own colour via data-color. |
data-color | hex / css | | Button background when theme=custom. |
data-text-color | hex / css | | Button label colour when theme=custom. |
data-radius | number (px) | 10 | Border radius of the button in pixels. 0–20. |
data-button-label | string | Try it on | Label shown on the injected button. |
data-attach-to | CSS selector | | If set, the button is injected after the matched element instead of after the script tag. |
<script
src="https://www.getonfitt.com/api/sdk"
data-api-key="sk_live_..."
data-theme="custom"
data-color="#e11d48"
data-text-color="#ffffff"
data-radius="8"
data-button-label="See it on me">
</script>The try-on modal inherits your brand colours. Every attribute below can also be set permanently through the Dashboard without touching code.
| Attribute | Type | Default | Description |
|---|---|---|---|
data-modal-theme | light | dark | light | Base colour scheme of the modal. Drives surface colours and text. Override individual colours with the attributes below. |
data-accent-color | hex | #7c3aed | Primary action colour. Drives the upload CTA, spinner, share button, and upload zone border. |
data-cta-color | hex | | Colour of the Shop this look button in the result step. Leave empty to use the accent colour. |
data-modal-bg | hex | #ffffff | Modal card background colour. |
data-modal-title-color | hex | #111111 | Colour of the modal title text ("Virtual Try-On" / "Your look"). |
data-close-icon-color | hex | #9ca3af | Colour of the ✕ close button icon. |
data-divider-color | hex / transparent | transparent | Colour of the horizontal line separating the modal header from the body. Set to transparent to hide. |
data-powered-by-color | hex | #9ca3af | The "Powered by" prefix text colour. The "OnFitt" brand name always stays in accent colour. |
Dark modal example:
<script
src="https://www.getonfitt.com/api/sdk"
data-api-key="sk_live_..."
data-theme="dark"
data-accent-color="#f59e0b"
data-modal-bg="#18181b"
data-modal-title-color="#ffffff"
data-close-icon-color="#71717a"
data-divider-color="#27272a"
data-powered-by-color="#52525b">
</script>After a successful try-on, a Share your look button appears. On mobile it triggers the native share sheet; on desktop it shows a copy-link popover. Configure what gets shared:
| Attribute | Type | Default | Description |
|---|
Every attribute above can be set once in the Dashboard's Customize panel and applied globally. No code changes needed. The SDK fetches your saved config on init and caches it for 1 hour.
CTA Button
Modal
Share
Priority
Your API key is embedded in client-side HTML and is visible to anyone who views your page source. To prevent unauthorised use, configure a domain allowlist in the Dashboard's Security panel.
Domain allowlist
How it works
Once the SDK script is loaded, window.OnFitt exposes two methods.
Opens the try-on modal programmatically. Useful for custom button placements or testing.
| Option | Type | Description |
|---|---|---|
apiKey | string | Required. Your OnFitt API key. |
_clothingUrls | string[] | Array of product image URLs to try on. |
theme / accentColor / modalBg / … | string | Any of the theming options listed above. |
// Open the modal with a specific product image
window.OnFitt.open({
apiKey: "sk_live_...",
_clothingUrls: ["https://yourstore.com/jacket.jpg"],
accentColor: "#e11d48",
modalBg: "#18181b",
modalTitleColor: "#ffffff",
});Runs the full init flow (usage check, then remote config fetch, then button injection). Use this when loading the SDK dynamically.
const s = document.createElement("script");
s.src = "https://www.getonfitt.com/api/sdk";
s.onload = () => window.OnFitt.init({
apiKey: "sk_live_...",
clothingUrls: ["https://yourstore.com/jacket.jpg"],
});
document.head.appendChild(s);Full OpenAPI spec. Authenticate with your API key as Authorization: Bearer sk_live_....