Skip to Content

Vizbl.js reference

The script and the button in your widget code, attribute by attribute.

Vizbl.js is the script in every dashboard's widget code. It defines the <vizbl-button> element, asks Vizbl which widget each button opens and with what data, and loads each widget's own script only when a button on the page needs it.

Install

Add the script once per site, in your theme's <head> or anywhere on the page. data-key holds your publishable key:

<script async src="https://cdn.vizbl.com/@vizbl/loader/dist/vizbl.js" data-key="pk_live_YOUR_PUBLISHABLE_KEY"></script>

Never put a secret key, sk_live_…, in data-key. Vizbl.js does not use it, hides every button and, for each <vizbl-button>, says so in the console: replace it with your publishable key and rotate the secret key, because it is now public.

Several products

Each Vizbl product has its own publishable key, and AI Try-On one per widget. If you sell several, keep one script and list one key per product in data-key, separated by spaces:

<script
  async
  src="https://cdn.vizbl.com/@vizbl/loader/dist/vizbl.js"
  data-key="pk_live_YOUR_WALL_ART_KEY pk_live_YOUR_CORE_AR_KEY"
></script>

For each button, Vizbl picks the key of the button's product. For AI Try-On, one widget's key serves every type: with several, the first one is used.

The button

<vizbl-button> goes where the button should appear. It stays hidden until Vizbl has found the product and the widget can open, then draws a button that opens it:

<vizbl-button product="wallart" sku="ART-1042"></vizbl-button>
AttributeValueFor
productRequired. The widget the button opens: see Products.Every product
sku, product-url, product-id, object-idExactly one: the store product this page shows. See How a button finds the product.Every product; object-id only Core AR, Rugs, Flooring
product-variant-idThe platform's id of the variant on screen, next to product-id.Every product
labelThe button's text. See Labels.Every product
unstyledDraws the button without Vizbl's styles. See Style the button.Every product
room-idThe room the viewer opens in. See Initial room.Wall Art, Rugs, Flooring
typewallcovering opens a Flooring product on the walls. See Wallcovering.Flooring
modear-viewer, ar-one-click or advanced-ar. See Modes.Core AR
variant-idThe model's material variant. See Variants and camera.Core AR
camera-orbit, min-camera-orbit, max-camera-orbitThe camera's start and limits. See Variants and camera.Core AR

The button follows its attributes: when your store's script changes product-variant-id as the shopper picks a colour or a size, the button asks again and opens the variant on screen.

Products

product takes one of five values. Each opens a widget whose package section documents what the shopper sees:

productOpensDefault label
wallartRoom Viewer, wall artView on your wall
rugsRoom Viewer, rugsView in your room
flooringRoom Viewer, flooringView in your room
flooring with type="wallcovering"Room Viewer, wallcoveringView on your wall
core-arCore ARThe mode's own: View in 3D & AR, View in AR or View in advanced AR
ai-try-onAI Try-OnTry it on

Default labels are in English whatever the widget's language; to show another, write the text inside the tag.

How a button finds the product

A button names your store's product in one of four ways. Use the one your store already has on the product page:

AttributeValueUse it when
skuThe product's SKU in your store.Your template can print the SKU, as the Wall Art and AI Try-On dashboards suggest.
product-urlThe full address of the product page, https://…. The query string and fragment are ignored.Your products have no SKU.
product-idYour platform's own id of the product, for example Shopify's product id. Add product-variant-id for the variant on screen.Your store is connected to Vizbl and has variants.
object-idThe id of the Vizbl object, from the dashboard.You sell Core AR, Rugs or Flooring and pick the object yourself, as their dashboards do.

sku, product-url and product-id find the Vizbl object through the product's link in the dashboard's Store products. Wall Art and AI Try-On also take the picture, the title and the size or product type from that link, so link the product there before you add its button.

Labels

Without a label, the button shows its product's default label. To replace it, in order of precedence:

  1. Write the text, or your own elements, inside the tag: <vizbl-button product="wallart" sku="ART-1042">See it on your wall</vizbl-button>.
  2. Set the label attribute: <vizbl-button product="wallart" sku="ART-1042" label="See it on your wall"></vizbl-button>.

Style the button

Vizbl.js styles its button with zero specificity, so any rule of your theme wins. To change a single value, set its CSS variable on the button or any of its parents:

vizbl-button {
  --vizbl-button-background: #111827;
  --vizbl-button-border-color: #111827;
  --vizbl-button-color: #ffffff;
  --vizbl-button-border-radius: 9999px;
}
VariableDefault
--vizbl-button-background#3556f0
--vizbl-button-border-color#3556f0
--vizbl-button-color#ffffff
--vizbl-button-border-radius0.5rem
--vizbl-button-font-familyinherit
--vizbl-button-font-size0.875rem
--vizbl-button-font-weight500
--vizbl-button-padding0.375rem 0.75rem

With unstyled, the button has no Vizbl styles at all: style vizbl-button button with your theme's classes. A Core AR button is the Core AR element itself: see Customization.

Hidden buttons

A button that cannot open its widget draws nothing. The <vizbl-button> element then carries data-state="hidden" and the reason in data-reason, and the browser console says why:

[vizbl] <vizbl-button> is not shown (missing_key): the vizbl.js script tag has no data-key.
ReasonWhat happenedFix
missing_keyThe script has no data-key.Copy the script again from your dashboard.
invalid_keyNo key in data-key is a valid, active publishable key.Copy the key again from your dashboard. It starts with pk_live_.
secret_keydata-key holds a secret key, sk_….Use your publishable key and rotate the secret key.
domain_not_allowedThe page's host is not on your allowed domains.Add the host exactly as the address bar shows it.
product_not_enabledNone of the keys belongs to the button's product, or that product's key is revoked or not allowed on this host.Add that product's key to data-key. See Several products.
unsupported_productproduct is missing or is not one of the five values.Fix the spelling.
missing_identifierThe button names none of sku, product-url, product-id and object-id, or more than one, or product-variant-id without product-id.Keep exactly one.
product_not_linkedNo Vizbl object is linked to this store product.Link the product in the dashboard's Store products, or name the object with object-id.
object_not_foundThe object does not exist or belongs to another account, or, for Core AR, it has no variant with this variant-id.Copy the object id and the variant id again from the dashboard.
object_not_readyThe object was rejected or hidden by moderation in the dashboard, or, for Core AR, the model is still processing.Check the object's status in the dashboard, or wait for the model to finish processing.
product_data_incompleteThe product's link lacks data the widget needs, such as an AI Try-On product type.Complete the product in the dashboard.
out_of_tokensCore AR only: the account ran out of tokens when a shopper tapped AR.Top up your balance on the dashboard's Billing page.
resolver_requiredThis button needs a Vizbl service that is not available yet.Name the product with object-id, or try again later.
unavailableVizbl refused the request, for example a product-url that is not a full address, or the widget's script could not load.Check the button's attributes, your connection and your Content Security Policy.

Automatic mode

On a page with the script and no <vizbl-button>, Vizbl.js places the buttons itself:

  1. It checks that the page is a product page: it has a JSON-LD Product, an og:type of product, or a Shopify, WooCommerce or BigCommerce product id. On any other page it does nothing.
  2. It names the product the ways it can: the page's address, its canonical address, the SKU of its JSON-LD Product (a GTIN or MPN matches only when your store uses it as the SKU), and the platform's product id.
  3. It asks Vizbl for every product linked to it, and puts their buttons in a row right after Add to cart. It finds that button on Shopify, WooCommerce, BigCommerce, Wix Stores and Tilda themes, and any button with the name or class add-to-cart.

The row is a <div data-vizbl-auto> of ordinary <vizbl-button> elements, which your theme can style or move. If the page has no Add to cart it finds, the console says so: place <vizbl-button> in your template instead.

A Flooring product meant for walls needs its own <vizbl-button product="flooring" type="wallcovering"> in your template.

A single <vizbl-button> anywhere on the page turns automatic mode off for that page, so a button you place yourself always wins.

Content Security Policy

If your site sends a Content Security Policy, add the sources Vizbl.js and the widgets it loads need:

DirectiveSourcesWhy
script-srchttps://cdn.vizbl.com 'wasm-unsafe-eval'Vizbl.js and the widgets' scripts. The 3D decoders of Room Viewer and Core AR run as WebAssembly.
connect-srchttps://api.vizbl.com https://cdn.vizbl.com blob:Vizbl's API, and the 3D models, rooms and lighting it points to.
img-srchttps://cdn.vizbl.com data: blob:Room photos, textures and the widgets' own images.
style-src'unsafe-inline'Vizbl.js and every widget add their own <style> elements.
font-srchttps://cdn.vizbl.com https://fonts.gstatic.comThe widgets' typeface, and a second typeface for some languages.
worker-srcblob:The 3D decoders run in a worker.

Some features need one more source:

  • Core AR on a computer shows a QR code that continues on the phone: add https://viewer.vizbl.com to script-src and img-src, and https://fonts.googleapis.com to style-src.
  • Core AR's AR on Android loads its AR engine from https://8wall.vizbl.com and, for rugs and floor coverings, a floor-segmentation runtime from https://cdn.jsdelivr.net: add both to script-src and connect-src.
  • Compressed models (Draco geometry, or KTX2 textures in Core AR) load their decoders from https://www.gstatic.com: add it to connect-src.
  • Wall Art and AI Try-On load the product's image from wherever your store hosts it: add that host to img-src and connect-src. It must also allow other sites to load the image, with an Access-Control-Allow-Origin header.

AI Try-On also uploads the shopper's photo to a storage address Vizbl's API returns. Before you enforce a policy, send it as Content-Security-Policy-Report-Only and open each widget you use, on a computer and on a phone: the browser console names any source the policy would block.

On this page