🚀 UI Package Integration Guide
The injectConfigurator function injects the OV25 configurator UI into existing DOM elements on your page. It finds elements by CSS selectors and either replaces or appends the configurator components.
📦 Installation
Install the package using npm:
💡 Note: Always use
@latestto ensure you have the most recent version with all the latest features and bug fixes.
📦 Usage
✅ Required Fields
| Field | Type | Description |
|---|---|---|
apiKey | StringOrFunction | OV25 API key |
productLink | StringOrFunction | Product ID or path (e.g. '217', 'snap2/4' for multi-product modular, 'range/126') |
selectors | SelectorsConfig | DOM targets for gallery, price, name, variants, swatches, configureButton |
callbacks | CallbacksConfig | addToBasket, buyNow, buySwatches (required); onChange (optional) |
Full Config Type
Minimal Example
🎯 Selectors
Each selector can be a string (CSS selector) or an object:
| Selector | Purpose | Required | Notes |
|---|---|---|---|
gallery | Main 3D/image container | Standard products | For multi-product modular configs, gallery chrome may live inside the configurator modal |
price | Price display | When not hiding pricing | Omit when flags.hidePricing: true |
name | Product name | Recommended | |
variants | Variant controls | Products with variants | Omit for products without variants |
swatches | Swatch selector | Products with swatches | Omit when no swatches |
configureButton | Button that opens configurator | Multi-product modular | Required for multi-product modular flows; optional for standard single-product |
Replace vs Append
replace: true– Replaces the target element's content with the configurator UIreplace: falseor omitted – Appends the UI inside the target element
Examples from Tests
Standard product with full selectors:
Multi-product (modular) with configure button:
Configure button only:
No variants – omit variants:
No pricing – omit price, set flags.hidePricing: true:
🎠 Carousel
Controls thumbnail display below the main image.
| Value | Description |
|---|---|
'none' | No carousel thumbnails |
'stacked' | Thumbnails stacked vertically |
'carousel' | Thumbnails in horizontal carousel |
Defaults: desktop: 'stacked', mobile inherits from desktop.
Examples
No carousel:
Stacked with max images:
Horizontal carousel:
Standard:
🎛️ Configurator
Controls how the configurator panel is shown and how variants are displayed.
Display Mode
| Desktop | Mobile | Description |
|---|---|---|
'inline' | 'inline' | Variants shown inline on the page |
'sheet' | 'drawer' | Full-screen sheet (desktop), bottom drawer (mobile) |
'sheet' | 'inline' | Sheet on desktop, inline on mobile |
Defaults: desktop: 'sheet', mobile: 'drawer' (when desktop is sheet) or 'inline' (when desktop is inline).
Trigger Style
'single-button'– One "Configure" button'split-buttons'– Separate Add to basket / Buy now
Default: 'single-button'
Variant Display Mode
| Value | Description |
|---|---|
'tree' | Hierarchical tree |
'list' | Flat list |
'tabs' | Tabbed groups |
'accordion' | Collapsible sections (desktop only; mobile falls back to tree) |
'wizard' | Step-by-step wizard |
Defaults: desktop: 'tree', mobile: 'list'
useSimpleVariantsSelector
When true, shows a single "Configure" button that opens the variant panel. Useful when you don't want inline variant controls.
Examples
Inline + wizard:
Sheet + tabs:
Inline + accordion:
Configure button only with simple selector:
📞 Callbacks
- addToBasket – Add configured product or scene to basket. When invoked by the UI, receives a normalized
OnChangePayload;skusandpricemay benulluntil those iframe messages have arrived. - buyNow – Checkout immediately. Same payload shape as addToBasket.
- buySwatches – Purchase selected swatches. Receives
Swatch[]andSwatchRulesData. - onChange – Optional. Fires when price or SKU updates. Payload is normalized by the UI package (see below);
skusandpriceare eachnulluntil that message type has been received at least once.
📋 Payload Types (skus and price)
The iframe emits CURRENT_SKU and CURRENT_PRICE as postMessage events. Wire JSON can differ between single-product and multi-product configurators (one billable line vs many). The UI package normalizes both into one contract before your callbacks run.
OnChangePayload is an alias of UnifiedOnChangePayload:
| Key | Type | When populated |
|---|---|---|
skus | UnifiedSkuPayload | null | After first CURRENT_SKU |
price | UnifiedPricePayload | null | After first CURRENT_PRICE |
Canonical fields for new integrations: use payload.skus.lines and payload.price.lines, and branch on payload.skus.mode / payload.price.mode ('single' \| 'multi').
Legacy (single-product only): when skus.mode === 'single', top-level skuString and skuMap match older integrations. For multi-product SKU payloads, mode === 'multi' and there is no top-level skuString—iterate lines instead.
Null-check and narrow mode before reading skuString:
Optional helpers (same package) if you handle raw postMessage outside injectConfigurator: normalizeSkuPayload, normalizePricePayload, parseIframeJsonPayload.
UnifiedSkuPayload (skus)
Discriminated union:
mode | Meaning | Top-level skuString / skuMap | Canonical |
|---|---|---|---|
'single' | One configured product | Set (backward compatible) | lines[0] plus legacy fields |
'multi' | Multiple billable lines in the scene | Absent | lines only |
OnChangeSkuPayload in TypeScript is an alias of UnifiedSkuPayload.
UnifiedPricePayload (price)
Order-level totals plus normalized per-line breakdown (replaces relying only on raw priceBreakdown / productBreakdowns from the iframe):
| Field | Description |
|---|---|
totalPrice, subtotal | Minor units (e.g. pence). |
formattedPrice, formattedSubtotal | Display strings. |
lines | Canonical per-line pricing; use for multi-product carts. |
priceBreakdown / productBreakdowns | Optional passthrough of raw iframe arrays for legacy tooling. |
OnChangePricePayload is an alias of UnifiedPricePayload.
Swatch and SwatchRulesData (buySwatches)
Example with onChange
⚙️ Optional Fields
configurationUuid
Saved configuration UUID for multi-product modular experiences. Restores a previously saved scene/configuration.
images
Override product images (e.g. for galleries with custom image sets).
uniqueId
Disambiguates when multiple configurators share global containers (e.g. mobile drawer, toaster).
branding
cssString – Custom CSS injected into configurator components. See Configurator Styling for CSS variables, class names, and data attributes.
flags
| Flag | Type | Description |
|---|---|---|
hidePricing | boolean | Hide price display |
hideAr | boolean | Hide AR features |
deferThreeD | boolean | Defer 3D loading |
showOptional | boolean | Show optional options |
forceMobile | boolean | Force mobile layout (e.g. for device frame testing) |
autoOpen | boolean | Auto-open configurator on load (non-inline only). Default false. |
🏷️ Product Types (productLink)
| Pattern | Example |
|---|---|
| Single product | '217', '58', '607' |
Multi-product modular (snap2/… path) | 'snap2/4', 'snap2/126' |
| Range | 'range/126', 'range/85' |
The snap2/ prefix is the URL convention for multi-product modular configurators; callback payloads still use mode: 'single' | 'multi', not this path string.
🔄 Multiple Configurators
Pass an array of configs. Each config must use distinct selectors (e.g. #gallery-1, #gallery-2). For standard configs, gallery and variants selectors must be unique across configs.
⚠️ Multi-product modular with
replace: trueon configure buttons: When multiple such configs usereplace: true, only one configurator instance is active at a time. Clicking a different configure button switches to that product's configurator.
Multi-product modular, configure buttons only:
4 products with gallery, price, name:
Inline variant controls per product – use configurator.displayMode: { desktop: 'inline', mobile: 'inline' }.
Ranges with variants – use productLink: 'range/126' with variants selector.
🌐 Global APIs
When the configurator is injected, these functions are exposed on window:
| Function | Description |
|---|---|
window.ov25OpenConfigurator(optionName?) | Open configurator; optionally focus an option group (e.g. 'wood finishes') |
window.ov25CloseConfigurator() | Close configurator |
window.ov25OpenSwatchBook() | Open swatch book |
window.ov25CloseSwatchBook() | Close swatch book |
Example:
🕰️ Legacy Format
A flat config format is supported for backward compatibility. Use addToBasketFunction, buyNowFunction, buySwatchesFunction (or addSwatchesToCartFunction as alias), onChangeFunction, and flat selector/carousel/configurator fields instead of callbacks, selectors, carousel, configurator. The grouped format above is preferred.
Built with ❤️ by the Orbital Vision team