Documentation

Guides, references, and machine-readable specs for developers and AI agents.

Raw .md
Drop forms onto any HTML site with inline, popup, drawer, or iframe embeds./docs/embed.md

Embed Widget (embed.js)

https://cdn.blokforms.com/embed.js is a lightweight, zero-dependency Web Component (<blok-form>) rendered inside an isolated Shadow DOM so host site CSS never breaks your form layout.

1. Inline Embed

html
<div
  data-blokform="frm_YOUR_FORM_ID"
  data-theme="light"
  data-locale="en"
></div>
<script src="https://cdn.blokforms.com/embed.js" async></script>

2. Popup Modal Trigger

Attach data-blokform-popup to any button or link:

html
<button
  type="button"
  data-blokform-popup="frm_YOUR_FORM_ID"
  data-title="Book a consultation"
  data-theme="light"
>
  Book a call
</button>
<script src="https://cdn.blokforms.com/embed.js" async></script>

Add data-auto-open-ms="5000" to automatically open the modal after 5 seconds.

3. Floating Slide-Over Drawer

html
<div
  data-blokform="frm_YOUR_FORM_ID"
  data-mode="drawer"
  data-position="right"
  data-trigger-label="Feedback"
></div>
<script src="https://cdn.blokforms.com/embed.js" async></script>

4. Responsive Iframe

html
<iframe
  src="https://cdn.blokforms.com/embed/frm_YOUR_FORM_ID"
  style="width:100%;border:0;min-height:480px"
  loading="lazy"
  title="BlokForms"
></iframe>

The hosted /embed/:id page automatically posts { type: "blokforms:resize", formId, height } via window.postMessage for auto-resizing iframes.

5. JavaScript Events & Programmatic API

js
document.addEventListener("blokform:success", (event) => {
  const { submissionId, message, booking, payment } = event.detail;
  console.log("Submitted:", submissionId, booking?.icsUrl);
});

document.addEventListener("blokform:error", (event) => {
  console.warn("Validation or submit error:", event.detail);
});

// Programmatic popup or drawer launch
window.BlokForms?.openPopup({
  formId: "frm_YOUR_FORM_ID",
  title: "Request a quote",
  locale: "nl",
});

6. CSS Theme Tokens & URL Prefill

Override any custom property on the container element:

css
[data-blokform="frm_YOUR_FORM_ID"] {
  --bf-accent: #059669;
  --bf-accent-hover: #047857;
  --bf-radius: 0.5rem;
  --bf-font: "Inter", system-ui, sans-serif;
}

Prefill any input field via query string when allowPrefill is enabled (default true):

text
https://yoursite.eu/contact?full_name=Ada+Lovelace&email=ada@example.eu&utm_source=newsletter