Public web component documentation for consent-dialog, consent-guard, and consent-missing.
Main entry component for consent UI and behavior.
| Attribute | Type | Default | Description |
|---|---|---|---|
| variant | standard | modern | modest | standard | Visual variant of the dialog. |
| expires-days | number | 180 | Cookie lifetime in days. |
| version | number | 0 | Consent schema version used for re-consent decisions. |
| locale | string | browser-derived | Locale override. Supported: en, no. |
| no-necessary | boolean | unset | Hides necessary section in UI. |
| no-preferences | boolean | unset | Hides preferences section in UI. |
| no-analytics | boolean | unset | Hides analytics section in UI. |
| no-marketing | boolean | unset | Hides marketing section in UI. |
| debug | boolean | unset | Enables debug output. |
| demo | boolean | unset | Disables auto-open and uses demo subscription status. |
| open | boolean | false | Controls open state. |
openDialog(): Promise<void> closeDialog(): Promise<void> checkSubscriptionStatus(): Promise<void>
<consent-dialog variant="standard" locale="en" version="1"> <span slot="dialog-title">Your privacy choices</span> <span slot="analytics-content">We use analytics to improve product quality.</span> </consent-dialog>
Conditionally renders content based on consent.
| Attribute | Type | Default | Description |
|---|---|---|---|
| consent | string | all categories | Consent expression to evaluate. |
Expression rules:
analyticsanalytics+marketinganalytics|marketing<consent-guard consent="marketing">
<iframe
title="YouTube video"
data-src="https://www.youtube.com/embed/abc123"
width="560"
height="315"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen>
</iframe>
</consent-guard>Note: when using iframes, use data-src to avoid loading before consent.
Fallback content for blocked consent-guard content.
| Attribute | Type | Required | Description |
|---|---|---|---|
| for | string | yes | Id of the related <consent-guard>. |
<consent-guard id="analytics-guard" consent="analytics"> <script type="text/plain" data-category="analytics" src="https://example.com/analytics.js"></script> </consent-guard> <consent-missing for="analytics-guard"> Please accept analytics cookies to continue. </consent-missing>
<script type="module" src="https://cdn.cookiekit.eu/cookiekit.esm.js"></script>
compilerOptions.isCustomElement for CookieKit tags.CUSTOM_ELEMENTS_SCHEMA where custom elements are used.