Headless: your own controls
Keep huesix’s 3D view, its rules and its prices, and draw the options in your site’s own design.
Headless or stage-only
-
headless: only the product. No panel, no buttons over the view: your page draws the options, cameras and AR (with the methods). Headless has no points of interest, try-on, tapping parts, dimensions or full screen, and ignores?hx-…page options: usestage-onlyto keep those. -
stage-only: no panel, but the view keeps its own buttons (cameras, AR, full screen, the total where the product shows it). Your page draws the options beside it.
Either way, every choice still goes through the product’s rules and prices, so what your controls show is always what can be bought.
The configurator’s loading card still shows while the product loads. To draw your own
loader, follow huesix:progress and hide the card:
huesix-configurator::part(preloader-card) { display: none; }. The product’s
picture stays until the 3D view is ready.
See it at full size in Aurelia Solitaire, built headless: the ring’s stones and metals on a dial round it, looks, views, lighting, Arabic, saved designs and a bag that checks out with huesix checkout, every control and its loader drawn by the page.
A working example
This is the code below, running on this page with our sample ring:
Total:
<huesix-configurator
headless
src="https://www.huesix.com/products/solitaire-ring/manifest.hxp"
style="--huesix-stage-ratio: 4 / 5"
></huesix-configurator>
<div id="options"></div>
<p>Total: <output id="total"></output></p>
<p id="said" role="status"></p>
<script type="module" src="https://www.huesix.com/embed/huesix.js"></script>
<script type="module">
const configurator = document.querySelector('huesix-configurator');
// Draws every visible group and option from getState().
async function draw() {
const state = await configurator.getState();
const groups = state.groups.filter((group) => group.visible);
document.querySelector('#options').replaceChildren(
...groups.map((group) => {
const fieldset = document.createElement('fieldset');
const legend = document.createElement('legend');
legend.textContent = group.name;
fieldset.append(legend);
for (const option of group.options.filter((o) => o.visible)) {
const button = document.createElement('button');
button.type = 'button';
button.textContent = option.priceText
? `${option.name} ${option.priceText}`
: option.name;
button.setAttribute('aria-pressed', String(option.selected));
button.disabled = !option.available; // a rule rules it out
if (option.reason) button.title = option.reason;
if (option.swatch) button.style.setProperty('--swatch', option.swatch);
button.addEventListener('click', () =>
group.selection === 'multiple'
? configurator.toggle(option.ref)
: configurator.select(option.ref),
);
fieldset.append(button);
}
return fieldset;
}),
);
document.querySelector('#total').textContent = state.priced ? state.price.formatted : '';
}
draw(); // getState() answers once the product is read, before its 3D view is in
configurator.addEventListener('huesix:change', (event) => {
// What the product's rules changed with the choice, in the shopper's words.
const said = event.detail.autoChanges.map((change) => change.reason).join(' ');
document.querySelector('#said').textContent = said;
draw();
});
configurator.addEventListener('huesix:blocked', (event) => {
document.querySelector('#said').textContent = event.detail.reason;
});
configurator.addEventListener('huesix:language', draw); // names in another language
</script>
Without its panel the configurator is the 3D view alone: as wide as its container, in
the product’s shape (Studio → Design) or yours with
--huesix-stage-ratio (4 / 5 here).
--huesix-height sizes a configurator with its panel, not a headless one
(except a showroom-layout product, where it’s the view’s height). With
stage-only it caps the view’s height on wide screens.
What getState() gives
{
"groups": [{
"id": "stone", "name": "Stone", "step": "stone",
"display": "swatch", // how the product's own panel shows it
"selection": "single", // or "multiple": use toggle()
"visible": true,
"options": [{
"ref": "stone:ruby", // for select(), deselect() and toggle()
"id": "ruby", "name": "Ruby",
"price": -900, "priceText": "−AED 945.00", "priceShown": -945,
"swatch": "#d0103a", // and/or "thumbnail": a picture's address
"selected": false,
"visible": true,
"available": true // false: a rule rules it out ("reason" says why)
}]
}],
"priced": true,
"price": { "formatted": "AED 4,410.00", "total": 4410, … },
"summary": [{ "groupId": "stone", "group": "Stone", "options": [{ "id": "diamond", "name": "Diamond" }] }],
"shareCode": "band*classic.metal*yellow-gold.setting*solitaire.stone*diamond",
"personal": [], // engraving and logos (below)
"looks": [], // ready-made looks: applyLook(id)
"display": { "optionPrices": "show", "unavailable": "dim", "swatchShape": "circle", … },
"currency": { "code": "AED", "withTax": true },
"labels": { "looks": "Looks", "lettering": "Lettering", … } // the product's own words
}
-
Draw only
visiblegroups and options: rules can hide them (a band width that only comes in platinum). -
Follow
display.unavailable:dimshows options a rule rules out (disabled, withreason),hideleaves them out. -
Redraw on
huesix:change: one choice can change others (the rules’autoChanges), and prices change with them. -
Names, prices and
labelsare in the language shown: redraw onhuesix:languagetoo. -
Show
priceTextonly wheredisplay.optionPricesisshow, as the product’s own panel does. -
An AR button of your own: show it where
xrSupport()saysar, and callenterAr()from its click. -
There’s no share link without the panel: keep the configuration’s
shareCodeand open it again with theconfigattribute.
Engraving and logos
state.personal lists the product’s personalisations with their limits
(maxLength, lines, fonts, colors)
and what’s filled in (value):
input.addEventListener('input', () =>
configurator.setPersonal('engraving', input.value ? { text: input.value } : null),
);
// A logo, where the product takes one
fileInput.addEventListener('change', () =>
configurator.uploadPersonal('logo', fileInput.files[0]),
);
The text is made to fit the product’s rules (its length, lines and lettering), and the design’s share code carries it, so your cart and the quote API see it too.
Stage-only: the view’s own buttons
With stage-only, the view keeps its camera, AR and full-screen buttons.
When something on it asks for a group (a hotspot, a part tapped), it fires
huesix:open-group for your panel to open it. For the panel’s foot,
getExtras() gives the notes (tax, made to order) and the product’s buttons
(a quote, a brochure), and runAction(id) runs one:
configurator.addEventListener('huesix:open-group', (event) => {
document.getElementById(`group-${event.detail.group}`)?.scrollIntoView();
});
const { notes, actions } = await configurator.getExtras();
for (const action of actions) {
const button = document.createElement('button');
button.textContent = action.label;
button.onclick = () => configurator.runAction(action.id);
foot.append(button);
}
In React
import { useRef, useState, type CSSProperties } from 'react';
import {
HuesixConfigurator,
type HuesixConfiguratorHandle,
type HuesixState,
} from '@huesix/react';
export function RingOptions({ src }: { src: string }) {
const configurator = useRef<HuesixConfiguratorHandle>(null);
const [state, setState] = useState<HuesixState | null>(null);
const refresh = () => configurator.current?.getState().then(setState);
return (
<>
<HuesixConfigurator
ref={configurator}
src={src}
headless
onReady={refresh}
onChange={refresh}
onLanguage={refresh}
style={{ '--huesix-stage-ratio': '4 / 5' } as CSSProperties}
/>
{state?.groups
.filter((group) => group.visible)
.map((group) => (
<fieldset key={group.id}>
<legend>{group.name}</legend>
{group.options
.filter((option) => option.visible)
.map((option) => (
<button
key={option.ref}
aria-pressed={option.selected}
disabled={!option.available}
onClick={() =>
group.selection === 'multiple'
? configurator.current?.toggle(option.ref)
: configurator.current?.select(option.ref)
}
>
{option.name} {option.priceText}
</button>
))}
</fieldset>
))}
<p>{state?.price.formatted}</p>
</>
);
}