Skip to Content
This is our docs site, visit our main website at strut.fit 
GuidesCustom Elements

Custom Elements

We recommend using StrutFit web components (Assistant Manager, Size Button, Try On Button, Fit Tip, and so on) so you get supported styling, accessibility, and behavior out of the box.

If you need full control over HTML and UX, you can build your own buttons or layouts and drive StrutFit through the global window.StrutFit API. The Assistant Manager script must still be on the page. Fit tip text in custom markup requires the fit tip script as well (see the Fit Tip tab).

Custom integrations still depend on the Assistant Manager. Without it, window.StrutFit will not be initialized and openAssistant will not work.

Custom controls

Call window.StrutFit?.openAssistant(mode, productCode?, options?) when the shopper interacts with your control (for example a click handler on your own <button>). Use optional chaining (?.) so your handler does not throw if StrutFit is not ready yet.

The first argument is the assistant mode. Pass the current product’s StrutFit product code as the second argument whenever the flow is product-scoped (sizing, size chart, try-on). FAQ and Find do not use a product code. An optional third argument is an object of overrides for that open only—see each tab below for the fields that apply. The Fit Tip tab describes custom markup instead of openAssistant.

const productCode = '{{ProductIdentifier}}'; // your StrutFit product code window.StrutFit?.openAssistant('sizing', productCode);

Optional third argument — only when you need to override what the assistant shows for this session:

  • productName, productImageURL — Overrides for the product title and image in the assistant.
  • defaultSizeUnit, defaultApparelSizeUnit — Size unit hints (for example 'US', 'EU').
window.StrutFit?.openAssistant('sizing', productCode, { productName: 'Custom title', productImageURL: 'https://example.com/image.png', defaultSizeUnit: 'US', });

For script setup and attributes, see Assistant Manager and Assistant Manager API.

Optional: wait until StrutFit is ready

It is recommended (not required) to enable or show StrutFit-driven controls only after the Assistant Manager has finished initializing, so clicks do not no-op while window.StrutFit is still loading.

Listen for the strutfit:ready event on window. Also check window.StrutFit?.ready when your code runs, so you still work if StrutFit became ready before your listener was attached.

Vanilla JavaScript:

function onStrutFitReady(callback) { if (window.StrutFit?.ready) { callback(); return; } window.addEventListener('strutfit:ready', callback, { once: true }); } onStrutFitReady(() => { // Show your custom button or remove disabled state });

The event includes detail.config if you need dashboard config; many integrations ignore it.

Last updated on