PrivacyKit

PrivacyKit Component Reference

Public web component documentation for consent-dialog, consent-guard, and consent-missing.

Table of Contents

  1. Script setup
  2. <consent-dialog>
  3. <consent-guard>
  4. <consent-missing>
  5. Style notes

Script setup

Load PrivacyKit once globally before using any of the custom elements.

<script type="module" src="https://cdn.privacykit.eu/privacykit.esm.js"></script>




Style notes

Avoid flickering before the web components finish loading. Without this snippet the slotted or guarded HTML can flash briefly when:

  1. consent-dialog can flash briefly if slotted elements are used and if they render before the component definition loads.
  2. consent-guard can flash briefly if it's used for conditional HTML and it renders before the component activates.
  3. consent-missing can flash briefly if consent-missing is used and it renders before the component activates.

Add styling in your light DOM to avoid flickering.

CSS
consent-dialog:not(:defined) [slot] {
  display: none;
}

consent-guard:not([active]) {
  display: none;
}

consent-missing:not([active]) {
  display: none;
}