Fine-tune light, shadows, borders, neumorphic
Light and shadows
Borders
Neumorphic
Display

CookieConsent <pm-cookie-consent>

Cookie consent: asks the visitor which optional cookies they allow, remembers the answer and tells your code.

Full screen
We use cookies to keep you signed in and, if you agree, to see which pages help. Read the privacy policy.

This component has no props to try here.

<script type="module"> import '@prismora/css'; import '@prismora/elements/cookie-consent'; </script> <pm-cookie-consent inline storage-key="docs-demo" heading="We use cookies"> We use cookies to keep you signed in and, if you agree, to see which pages help. <a href="/docs">Read the privacy policy</a> . </pm-cookie-consent>

Overview

It shows until the visitor chooses, then stays away (the choice is kept in localStorage; change version to ask everyone again after your cookies change). "Accept all" and "Reject all" look the same and sit side by side, nothing optional is switched on beforehand, and the page stays usable while it is shown. Load analytics or marketing scripts only after pm-consent says so, or read the choice with readConsent() on later visits. show() opens it again, for a "Cookie settings" link in the footer.

Attributes

AttributeTypeDefaultDescription
openbooleanfalseShown. Set by the element: open until a choice is stored.
headingstring—Title of the notice (default "Cookies").
descriptionstring—One or two sentences on what the cookies are for.
categoriesConsentCategory[]—The choices: [{ id, label, description?, required? }]. Default: necessary, analytics, marketing.
storage-key
prop: storageKey
string—Name of the stored choice (default consent). Use the same key on every page of a site.
versionstring—Version of your cookie list (default 1). A stored choice of another version is asked again.
position'start' | 'center' | 'end'—Corner of the screen: start (default), center or end.
inlinebooleanfalseStay in the flow of the page instead of floating (for a settings page).
accept-label
prop: acceptLabel
string—Text of the accept button (default "Accept all").
reject-label
prop: rejectLabel
string—Text of the reject button (default "Reject all").
customize-label
prop: customizeLabel
string—Text of the button that shows the choices (default "Customize").
save-label
prop: saveLabel
string—Text of the button that stores the chosen switches (default "Save choices").

Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.

Events

EventReact / Svelte propDescription
pm-consentonPmConsentThe visitor chose. detail.choice has one boolean per category; detail.action is accept, reject or save.

Slots

SlotDescription
(default)The explanation, instead of description. Link to your privacy policy here.

CSS parts

PartDescription
::part(base)The notice.

Methods

show(), reset()