Skip to content

C15tDialog

A headless consent preferences dialog. Shows when the user clicks "Preferences" in the banner or when setActiveUI('dialog') is called. Displays checkboxes for each consent category.

Usage

Default UI

vue
<template>
  <C15tDialog />
</template>

Custom UI

vue
<template>
  <C15tDialog v-slot="{ displayedConsents, consents, toggle, saveCustom, acceptAll, close }">
    <div class="my-dialog-overlay" @click.self="close">
      <div class="my-dialog">
        <h2>Cookie Preferences</h2>
        <label v-for="ct in displayedConsents" :key="ct.name">
          <input
            type="checkbox"
            :checked="consents[ct.name]"
            :disabled="ct.disabled"
            @change="toggle(ct.name, $event.target.checked)"
          />
          {{ ct.description }}
        </label>
        <button @click="saveCustom">Save</button>
        <button @click="acceptAll">Accept all</button>
      </div>
    </div>
  </C15tDialog>
</template>

Slot Props

PropTypeDescription
displayedConsentsConsentType[]Consent types to display, based on user's jurisdiction
consentsPartial<ConsentState>Current consent state object
toggle(name, value) => voidToggle a consent checkbox (doesn't save)
saveCustom() => voidSave the current checkbox selections
acceptAll() => voidAccept all categories
close() => voidClose the dialog, return to banner

Behaviour

  • Renders inside a <Teleport to="body">
  • Only visible when activeUI === 'dialog'
  • Necessary cookies are shown as always-active (disabled checkbox)
  • Clicking the backdrop calls close()