Skip to content

Call-to-action modal

The modal is an overlay with a title, a description and a button. Typical uses: “join to keep watching”, newsletter sign-ups, or the end of a free preview.

Play it: the modal opens at 0:04.
  • On pause, by default. Pausing opens it, resuming closes it.
  • At a given second, with modal-delay: when playback crosses that second, the video pauses and the modal opens. After that, pausing doesn’t reopen it until the viewer has closed it once.

It never opens:

  • if it has no content: you need at least modal-title, modal-description or a custom modal-cta-text;
  • with modal-enabled="false";
  • when the browser pauses the video itself (background tab, app minimised on a phone);
  • in Picture-in-Picture or while casting;
  • after pause({ silent: true }).
<!-- On pause -->
<vega-player
src="/trailer.mp4"
modal-title="Members only"
modal-description="Get unlimited access to every video."
modal-cta-text="Join now"
modal-cta-url="/join">
</vega-player>
<!-- At 0:30 -->
<vega-player src="/preview.mp4" modal-title="Free preview ended" modal-cta-text="Subscribe" modal-cta-url="/subscribe" modal-delay="30"></vega-player>

modal-title and modal-description accept a few inline tags: <br>, <b>, <strong>, <i>, <em>, <span> and <small>. Other tags become plain text and all attributes are removed.

<vega-player
modal-title="Only for <strong>Members</strong>"
modal-description="Unlimited access.<br><small>Cancel anytime.</small>"
modal-description-color="#a48c79">
</vega-player>

modal-cta-url only accepts http:, https:, mailto: and tel: links; anything else (such as javascript:) becomes #.

AttributeDefault
cta-bg-colorcolor-primary
cta-text-color#000
cta-hover-bg-color#fff
cta-hover-text-color#000
player.showModal(); // opens it and moves focus inside
player.hideModal(); // closes it and restores focus
player.isModalVisible; // true / false
player.addEventListener('vega-player:cta-click', (e) => {
analytics.track('cta', { url: e.detail.url });
});

The modal has role="dialog" and aria-modal="true". Focus moves to its close button when it opens, Tab cycles inside it, Escape closes it, and focus returns to where it was.