Skip to main content

<st-cookie-consent>

JSON type: CookieConsent

Fixed bottom consent bar with explicit choices: accept all, reject all optional cookies, or (with categories and a settings-button-text) open a settings panel to allow categories one by one. Optional categories are off until the visitor turns them on. The choice is kept in localStorage (storage-key, default sankhya_ui_cookie_consent; storage errors are ignored) and the bar renders nothing once a choice exists. Fires cookie-consent-accept, cookie-consent-refuse or cookie-consent-save (detail { status, categories }). The default slot replaces the message text. privacy-policy-link opens in the same tab for a site path, in a new tab for an external URL.

While a modal is open (<html data-st-modal-open>, set by st-quote-dialog) the bar is hidden (visibility: hidden) and inert, and it reappears unchanged when the modal closes. While the mobile nav drawer is open (<html data-st-drawer-open>, set by st-header) the bar is not displayed.

While the bar is shown its height is published as --st-cookie-banner-height on <html> (removed when it is dismissed), so a page's footer can pad its last row above the bar.

Usage​

import '@sankhyatronics/sankhya-cms/cookie-consent'; // registers <st-cookie-consent>

Properties​

PropertyAttributeTypeDefaultDescription
messagemessagestring''
acceptButtonTextaccept-button-textstring'Accept'
refuseButtonTextrefuse-button-textstring'Reject'
settingsButtonTextsettings-button-textstring'Settings'Label of the button that opens the settings panel. Shown only with categories.
saveButtonTextsave-button-textstring'Save choices'
settingsHeadingsettings-headingstring'Cookie settings'
categories—CookieCategory[][]Cookie groups for the settings panel. Without any, the bar only offers accept and reject.
privacyPolicyLinkprivacy-policy-linkstring''
privacyPolicyTextprivacy-policy-textstring'Privacy Policy'
storageKeystorage-keystring'sankhya_ui_cookie_consent'

Events​

EventDetailDescription
nameCustomEvent
cookie-consent-acceptEvery category allowed.
cookie-consent-refuseOnly required categories allowed.
cookie-consent-saveThe categories picked in the settings panel.

See the live examples in Storybook.