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 — powered by generative AI.
Paste one <script> tag on your product page. The SDK auto-detects your product image and injects a "Try this on" button beneath it.
<script
src="https://getonfitt.com/sdk.js"
data-api-key="sk_live_YOUR_KEY">
</script>sk_live_YOUR_KEY with your API key from the dashboard.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 (best results — AI picks the best angle):
<script
src="https://getonfitt.com/sdk.js"
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 → 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 this 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://getonfitt.com/sdk.js"
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-accent-color | hex | #7c3aed | Primary action colour — drives the upload CTA, spinner, share button, and upload zone border. |
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://getonfitt.com/sdk.js"
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 |
|---|---|---|---|
data-share-url | URL | | The URL shared when a shopper taps Share. Typically your product page or brand homepage. If empty, the Share button is hidden. |
data-share-message | string | Check out my look! | The message text included in the share payload (mobile share sheet). |
data-share-url="https://yourstore.com/products/classic-jacket"
data-share-message="I just tried this on with OnFitt — check it out!"Every attribute above can be set once in the Dashboard → 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
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",
shareUrl: "https://yourstore.com/products/jacket",
});Runs the full init flow (usage check → remote config fetch → button injection). Use this when loading the SDK dynamically.
const s = document.createElement("script");
s.src = "https://getonfitt.com/sdk.js";
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_....