Reference

ConsentBanner

The reader's say over the scripts that track them: shown until they choose, Decline as easy as Accept, and the choice kept. Accepting loads the meta.scripts entries marked "load": "consent", then and on every later visit; nothing loads before.

ConsentBanner(_ text: String, accept: String, decline: String, label: String) { … }

Since 6.2.0

No preview for this one: the example below shows how it is written.

Example

wf

ConsentBanner("We would like to count visits to improve the site. Nothing is shared.", accept: "Allow", decline: "No thanks") { Link("How we count", to: "/learn") }

With its own words only

wf

ConsentBanner("May we use analytics cookies?")

Props

Props of ConsentBanner
PropTypeUnsetMeaning

text

String (positional)

—

What is asked, drawn above the block and the two buttons

accept:

String

Accept

The yes button's words; pressing it loads the "load": "consent" scripts and remembers the answer

decline:

String

Decline

The no button's words, drawn first and as Accept is; the answer is remembered and nothing loads

label:

String

Cookies

The banner's accessible name (aria-label)

Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.

Flags and cases

A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.

No flags of its own.

Events

Every element also takes the props, the events and the attribute families listed on every element.

Slots

children

Renders with the class wf-consent, stable across releases, so a stylesheet may target it.

These controls list the props' cases; the example below shows them written.