On this page
@addTagHelper *, Webority.Ui.RazorWiring it up
Call initConsent once before the first render, render the banner once near the root, and give visitors a way back in.
Categories
List only the optional categories the site sets cookies for. Essential always shows, and a category left out is never granted.
Reopening the banner
Withdrawing consent must be as easy as giving it, so one attribute on any link reopens the banner.
Every option
Every value of every prop, one cell each.
title
title="How we use cookies"
description
description="We use cookies to measure visits and campaigns."
policy-href
policy-href="/cookie-policy"
policy-label
policy-label="Privacy notice"
analytics-description
analytics-description="Measures how visitors use the site."
functional-description
functional-description="Remembers the choices you make."
marketing-description
marketing-description="Measures how well our campaigns work."
categories
categories="analytics functional marketing" (default)
categories="analytics"
categories="functional"
categories="marketing"
position
position="bottom-left" (default)
position="bottom-right"
position="bar"
standalone
standalone="false" (default)
standalone="true"
preview
preview="true": draws open and saves nothing
class
class: extra classes on the element, no visible change here
Guidance
What to do, and what to avoid.
Use it when
- Any product surface that sets non-essential cookies (analytics, ads, feature personalization).
- You want one shared consent record across the website and its subdomains.
Reach for something else when
- You need to announce something to every visitor, not ask a compliance question. → AppBanner
- You are building the Razor head include that loads the tags and the consent record (the app-analytics-head tag).
- You are starting analytics or tags by hand beside the banner. The choice saved through initConsent decides which analytics start: the analytics category turns PostHog capture and Clarity on, and Consent Mode holds Tag Manager's tags until analytics consent, or marketing consent when adStorage is on.
Reference
Try every prop, read the full list, and check keyboard and screen reader behaviour.
12 props. The 5 most used come first.
Used on most screens 5 props
| Prop | Type | Default | Description |
|---|---|---|---|
| positiondefault bottom-left | bottom-left | bottom-right | bar | bottom-left | The corner it pins to, or the full-width bar. bar is a slim full-width bar along the bottom at every width. |
| titledefault Cookies on this site | string | Cookies on this site | Title, and the dialog's accessible name. |
| descriptiondefault - | string | - | The explanation above the buttons. |
| policy-hrefdefault - | string | - | Link to the cookie policy; no link when omitted. |
| categoriesdefault analytics functional marketing | string | analytics functional marketing | The optional categories to show, separated by spaces, from analytics, functional and marketing. Essential always shows and is not listed. A category left out has no row, saves as off and is never granted by Accept all. An unknown name throws. |
Less common 7 props
| Prop | Type | Default | Description |
|---|---|---|---|
| policy-labeldefault Cookie policy | string | Cookie policy | The policy link's text. |
| analytics-descriptiondefault - | string | - | What the analytics category covers. |
| functional-descriptiondefault - | string | - | What the functional category covers. |
| marketing-descriptiondefault - | string | - | What the marketing category covers. |
| previewdefault false | bool | false | Draw the banner open without reading or saving consent, for a design surface that never ran initConsent. Nothing is stored. |
| standalonedefault false | bool | false | Render sealed in a shadow root with bundled styles, for a page that does not load @webority/theme. |
| classdefault - | string | - | Extra classes on the element; passes through as a plain HTML attribute. |
Method on the element, called from your own script (the <app-analytics-head> include already does this for you): open({ settings, focus }), close(). Event: wui-consent-save with detail = { analytics, functional, marketing }.
Screen reader
3 notes- The panel is a dialog named by its title.
- There is no close button by design, so the only way out is a choice: Accept all, Reject all, or Save preferences in settings mode.
- Escape does not dismiss it, for the same reason as the missing close button.