Widget elements

When a user clicks the GreenLeaze button, a modal opens and displays the rental offer.

This page documents the configurable elements of the modal, the parameters accepted by each element, and the postMessage events emitted by interactive elements.

Sending data to the modal

Widget elements are configured through the data field of a greenleaze:dataChange event sent to the modal iframe.

const iframe = document.querySelector("#greenleaze-modal-container iframe");

iframe.contentWindow.postMessage(
  {
    type: "greenleaze:dataChange",
    modal: "product",
    data: {
      // widget elements
    },
    content: {
      // prices per duration
    },
    product: {
      // product info
    },
    variantId: "your-variant-id",
  },
  "*",
);

The modal can be updated at any time after it has loaded. Listen for greenleaze:modalInitialized to know when the iframe is ready.

Warning: all fields are processed together. If you send a partial payload, omitted fields may be unset. Always include the full payload when updating the modal.

Payload shape

{
  type: "greenleaze:dataChange",
  modal: "product",
  data: { ... },
  content: { ... },
  product: { ... },
  cart: [ ... ],
  variantId: "..."
}
FieldRequiredDescription
typeYesMust be greenleaze:dataChange.
modalYesModal type: product or cart.
dataYesWidget elements documented on this page.
contentYesMonthly prices per duration.
productProduct modal onlyProduct information.
cartCart modal onlyCart items.
variantIdYesVariant identifier.

Configuration-gated elements

Some elements can only be overridden through the live data event if the corresponding option is enabled in your GreenLeaze configuration.

ElementBehavior if not enabled
Illustration background colorEvent value is ignored.
Subscribe / Booking button label and styleEvent value is ignored.
buttonModeConfiguration value is used instead.

Contact GreenLeaze if one of these options needs to be enabled for your shop.


Title

Main title displayed at the top of the modal. It can be configured as a plain string or as multiple styled segments.

Default: enabled. A fallback title is displayed if no title is configured.

Example

{
  "title": [
    { "text": "Your subscription with " },
    { "text": "GreenLeaze", "color": "#0d5537", "bold": true }
  ]
}

Parameters

ParameterTypeRequiredDescription
textstringYesSegment text.
colorstringNoHex color, for example #0d5537.
boldbooleanNoRenders the segment in bold when set to true.

Event emitted: none.


Subscribe and Booking buttons

The modal can display a Subscribe button, a Booking button, or both.

Each button has its own label and style. Both buttons emit the same confirmation event, with the selected action available in the action field.

Default: Subscribe button only.

Button mode

{
  "buttonMode": "both"
}
ValueResult
subscribeShows the Subscribe button only.
bookingShows the Booking button only.
bothShows both buttons, stacked.

buttonMode is configured by default through features.buttonMode. To override it live through data.buttonMode, live override must be enabled in the GreenLeaze configuration.

Button labels and styles

{
  "subscribeButton": {
    "label": "Subscribe",
    "style": "background:#0d5537;border-radius:10px"
  },
  "bookingButton": {
    "label": "Book now",
    "style": "background:transparent;color:#0d5537;border:2px solid #0d5537;border-radius:10px"
  }
}
ParameterTypeRequiredDescription
labelstringNoButton text. A default label is used if omitted.
stylestringNoInline CSS declaration string applied to the button.

The style value must use standard inline CSS syntax:

property:value;property:value

Pseudo-states such as :hover are not supported.

Warning: button labels and styles can only be overridden live if this is enabled in your GreenLeaze configuration.

Event emitted

{
  "type": "greenleaze:submitGreenleazeModal",
  "action": "subscribe",
  "modal": "product",
  "duration": 24,
  "variantId": "your-variant-id",
  "product": {},
  "data": {},
  "instanceId": "default"
}
FieldDescription
actionsubscribe or booking, depending on the clicked button.
durationSelected rental duration, in months.
modalproduct or cart.
variantIdVariant identifier.
instanceIdIdentifier of the affected widget instance.
window.addEventListener("message", (e) => {
  if (e.data.type === "greenleaze:submitGreenleazeModal") {
    if (e.data.action === "booking") {
      // Redirect to the bookingUrl returned when the transaction is created.
    } else {
      // Continue with the subscription flow.
    }
  }
});

Warning: no action is triggered automatically. Your integration decides what to do when the event is received.


Arguments

List of commercial arguments displayed on the left side of the modal.

Default: enabled. A fallback list of four arguments is displayed if no content is configured.

{
  "arguments": [
    {
      "label": "Theft / breakage warranty available",
      "icon": "https://cdn.example.com/icon.svg"
    }
  ]
}
ParameterTypeRequiredDescription
labelstringYesArgument text.
iconstringYesIcon URL. SVG and PNG are supported.

Event emitted: none.



Trustpilot badge

Displays the Trustpilot rating under the commercial arguments. It can also be made clickable.

Default: disabled.

Example

{
  "trustpilotBadge": {
    "rating": 4.6,
    "reviewCount": 1106,
    "clickable": true
  }
}

Parameters

ParameterTypeRequiredDescription
ratingnumberYesRating displayed as stars. Must be between 0 and 5.
reviewCountnumberNoNumber of reviews displayed next to the brand name.
clickablebooleanNoWhen set to true, the badge emits a click event.

Event emitted

Only emitted when clickable is set to true.

{
  "type": "greenleaze:trustpilotBadgeClicked",
  "instanceId": "default"
}
FieldDescription
instanceIdIdentifier of the affected widget instance.

Conditions link

Displays a text button below the duration selector, for example View conditions.

Default: disabled.

Example

{
  "conditionsLink": {
    "label": "View conditions",
    "link": "https://your-shop.com/conditions"
  }
}

Parameters

ParameterTypeRequiredDescription
labelstringYesText displayed on the button.
linkstringYesURL associated with the button.

Event emitted

{
  "type": "greenleaze:conditionsLinkClicked",
  "url": "https://your-shop.com/conditions",
  "instanceId": "default"
}
FieldDescription
urlConfigured URL.
instanceIdIdentifier of the affected widget instance.

Warning: the link is not opened automatically. Your integration must handle the event and decide what to do with the URL.


Call button

Displays a secondary contact button with an optional icon.

The configured value is typically a tel:+33... URI, but any string can be passed and handled by your integration.

Default: disabled.

Example

{
  "callButton": {
    "label": "Call me back",
    "value": "tel:+33123456789",
    "icon": "https://cdn.example.com/phone.svg"
  }
}

Parameters

ParameterTypeRequiredDescription
labelstringYesText displayed on the button.
valuestringYesValue passed in the emitted event. Usually a tel: URI.
iconstringNoURL of the icon displayed before the label.

Event emitted

{
  "type": "greenleaze:callButtonClicked",
  "value": "tel:+33123456789",
  "instanceId": "default"
}
FieldDescription
valueConfigured value.
instanceIdIdentifier of the affected widget instance.

Warning: no action is triggered automatically. Your integration decides what to do with value.


Footer

Displays a strip at the bottom of the modal with a two-part tagline and an action button.

Default: disabled.

Example

{
  "modalFooter": {
    "labelOne": "Did you know your employer can fund part of your rental?",
    "labelTwo": "Up to €900 with the FMD scheme.",
    "buttonLabel": "Learn more →"
  }
}

Parameters

ParameterTypeRequiredDescription
labelOnestringYesIntroductory text.
labelTwostringYesHighlighted text displayed next to labelOne.
buttonLabelstringYesText displayed on the footer action button.

Event emitted

{
  "type": "greenleaze:footerActionClicked",
  "instanceId": "default"
}
FieldDescription
instanceIdIdentifier of the affected widget instance.

Illustration background

Controls the background color displayed behind the commercial argument icons.

Default: disabled.

Example

{
  "illustrationBackgroundColor": "#f5f6f7"
}

Parameters

ParameterTypeRequiredDescription
illustrationBackgroundColorstringnullYesHex color value, or null for a transparent background.

Event emitted: none.


Duration selector

Controls how the user selects the rental duration.

Default: slider.

Example

{
  "durationSelector": "buttons"
}

Parameters

ParameterTypeRequiredDescription
durationSelectorstringYesDisplay mode. Accepted values are slider and buttons.

Accepted values

ValueDescription
sliderHorizontal slider with labels underneath.
buttonsRow of clickable duration buttons.

Event emitted: none directly.

The selected duration is included in the greenleaze:submitGreenleazeModal event when the user confirms.


Handling widget events

Use a single message listener to handle all interactive widget events.

window.addEventListener("message", (e) => {
  switch (e.data.type) {
    case "greenleaze:submitGreenleazeModal":
      // e.data.action: "subscribe" | "booking"
      // e.data.duration: selected rental duration
      // e.data.instanceId: affected widget instance
      //
      // For "booking", redirect to the bookingUrl returned when
      // the transaction is created.
      break;

    case "greenleaze:trustpilotBadgeClicked":
      // e.data.instanceId
      break;

    case "greenleaze:conditionsLinkClicked":
      // e.data.url
      // e.data.instanceId
      break;

    case "greenleaze:callButtonClicked":
      // e.data.value
      // e.data.instanceId
      break;

    case "greenleaze:footerActionClicked":
      // e.data.instanceId
      break;
  }
});

Complete payload example

A full data payload combining all widget elements.

{
  "title": [
    { "text": "Your subscription with " },
    { "text": "GreenLeaze", "color": "#0d5537", "bold": true }
  ],
  "buttonMode": "both",
  "subscribeButton": {
    "label": "Subscribe",
    "style": "background:#0d5537;border-radius:10px"
  },
  "bookingButton": {
    "label": "Book now",
    "style": "background:transparent;color:#0d5537;border:2px solid #0d5537;border-radius:10px"
  },
  "arguments": [
    {
      "label": "Theft / breakage warranty available",
      "icon": "https://cdn.example.com/warranty.svg"
    },
    {
      "label": "12-month warranty included",
      "icon": "https://cdn.example.com/shield.svg"
    },
    {
      "label": "French support 6/7 days",
      "icon": "https://cdn.example.com/support.svg"
    },
    {
      "label": "More than 8000 satisfied customers",
      "icon": "https://cdn.example.com/customers.svg"
    }
  ],
  "trustpilotBadge": {
    "rating": 4.6,
    "reviewCount": 1106,
    "clickable": true
  },
  "conditionsLink": {
    "label": "View conditions",
    "link": "https://your-shop.com/conditions"
  },
  "callButton": {
    "label": "Call our experts",
    "value": "tel:+33123456789",
    "icon": "https://cdn.example.com/phone.svg"
  },
  "modalFooter": {
    "labelOne": "Did you know your employer can fund part of your rental?",
    "labelTwo": "Up to €900 with the FMD scheme.",
    "buttonLabel": "Learn more →"
  },
  "illustrationBackgroundColor": "#f5f6f7",
  "durationSelector": "buttons"
}
window.addEventListener("message", (e) => {
  switch (e.data.type) {
    case "greenleaze:submitGreenleazeModal":
      // e.data.action ("subscribe" | "booking"), e.data.duration, e.data.instanceId
      // for "booking", redirect to the bookingUrl returned at transaction creation
      break;
    case "greenleaze:trustpilotBadgeClicked":
      // e.data.instanceId
      break;
    case "greenleaze:conditionsLinkClicked":
      // e.data.url, e.data.instanceId
      break;
    case "greenleaze:callButtonClicked":
      // e.data.value, e.data.instanceId
      break;
    case "greenleaze:footerActionClicked":
      // e.data.instanceId
      break;
  }
});