Your next page is taking shape...

Opening Your Next Page…

Loading the guide and preparing its examples for you to explore. The page will appear here automatically when it’s ready, so you can keep this view open without refreshing.

Made for Preact. Built to be yours.

Overlays & Actions

Consent Manager

A two-level cookie dialog. The summary asks for a decision, and settings change each category. It opens on its own until a decision for the current version is stored. Reveal the right amount of context without losing the user's place in the interface. Keep the trigger, content and dismissal behavior working as one interaction. Import it from @/components/kamod-ui/consent-manager.

Source · API reference · Theming · Styles


Interactive Live Preview
Try it. Make it yours.

Installation

Import the consent manager from @/components/kamod-ui/consent-manager. Labels default to English. Pass labels for another language.

Install PackagesTerminal
pnpm add @kamod-ch/ui

Copy an example with @kamod-ch/ui or the matching @kamod-ch/ui/… subpath. The code block switches between those two installs. Connect The Global Theme CSS and Tailwind Source Detection before your first render.

Import SetupTypeScript
import { ConsentManager, ConsentManagerTrigger, useConsent } from "@kamod-ch/ui";

Usage

Give each category an id, title and description. Mark the categories that must stay on with required. Raise version when the policy changes so an older decision is asked for again. Read the result with useConsent inside the provider, and load optional scripts only after hasConsent returns true.

Import SetupTypeScript
import { ConsentManager } from "@kamod-ch/ui";

Choose a complete composition from the examples below; required child components and props vary by pattern.

Usage PatternTypeScript
<ConsentManager version="2026-11" categories={categories} onConsentChange={saveDecision}>
  <ConsentManagerTrigger>Cookie settings</ConsentManagerTrigger>
</ConsentManager>

Component Examples & Variants

Explore Consent Manager in Different Contexts, from the starting pattern to the compositions below. Begin with Standard, then compare the examples that match your content, state and layout. These are working patterns to adapt, not a list of interchangeable variant values: check the API Reference before using a prop or combining behaviors. Look at the surrounding labels, supporting text and spacing as well as the component itself.

Read the Result and Its Implementation Together. Use each showcase’s Code view to inspect imports and composition, or its Prompt view to prepare a setup or adaptation brief. Try the narrow preview and local theme controls before connecting real data, and use Reset to return an example to its initial state. Keep layout changes in class utilities where appropriate; follow the Component Styles Guide for hierarchy and the Theming Guide for shared surfaces and colors. The Accessibility Notes explain what to preserve when making those changes.

Standard

Ask for a Decision Before Optional Scripts Run. ConsentManager opens on the summary until a decision for this version is stored. Accept all and Necessary only are both full-width actions, with Necessary only immediately after Accept all. Settings switches to the category list in the same dialog.

Escape and the overlay do not dismiss it. Compare Dialog for panels that should close without a decision.

Interactive Live Preview
Try it. Make it yours.

German

Keep the Legal Copy Outside the Component. Pass labels and category text in the voice of the product. The default copy is English. This example uses German du-form, sentence case, and no exclamation marks.

Changing a label does not change what is stored. The stored record is the category ids, the version and the time of the decision.

Interactive Live Preview
Try it. Make it yours.

Gate a Script

Load Optional Code Only After Consent. Call useConsent().hasConsent(id) from a child of ConsentManager. Required categories are allowed before a decision. Optional categories stay off until they are saved as enabled.

A missing or unreadable record is treated as no decision. The hook throws when it is called outside the provider.

Interactive Live Preview
Try it. Make it yours.

Accessibility

Build the Complete Interaction, Including the Parts Outside Consent Manager. The notes below distinguish the current implementation from the labels, content and behavior your application supplies. Start with the Live Preview, check the Props and Data Reference, and test the finished composition with real content rather than assuming that an unchanged visual example covers every use case.

Built-in Behavior and Defaults

ConsentManager opens a modal dialog until a valid decision for the current version is stored, then stays closed until ConsentManagerTrigger or useConsent().open() shows the settings level. Escape, the overlay and a close button do not dismiss it. Dialog is used with dismissible={false} so other dialogs still close on Escape.

Labels and Relationships

The summary and settings levels each provide a title and description. Every switch uses the category title as its accessible name. Required categories stay on and disabled, so the state is not conveyed by color alone.

Keyboard and Focus

Initial focus is the first action, Accept all. Necessary only is the same size and the next control in order. Settings replaces the summary inside the same dialog and moves focus to the new heading. Back returns focus to the summary heading. After a decision, focus returns to the trigger that reopened the dialog.

States and Integration Details

Do not load optional scripts before hasConsent returns true. A stored decision from another version is ignored. A throwing or unreadable storage adapter is treated as no decision and must not crash the page.

Verify the Complete Interaction

Check Behavior as Well as Markup. Work through these scenarios in the application where the component will be used. Automated checks can help find structural problems; also review the reading experience with a screen reader, keyboard focus and the actual feedback from your application.

  1. Open with the keyboard, accept only necessary categories, reload, and confirm optional scripts stay unloaded.
  2. Try Escape and the overlay, then each action. Only a decision may close the dialog.
  3. Reopen from the trigger and confirm the switches match the saved decision, including a required category that stays on.

Recheck the result after changing Theme Tokens, translations or class overrides. Include text enlargement, narrow layouts and reduced-motion settings where animation is present. Inspect the Component Source when a behavior differs from your expectation; a role or state attribute does not implement keyboard interaction by itself.

For background, read the WAI-ARIA Authoring Guidance and Keyboard Interface Guidance. These explain the patterns; verify browser and assistive-technology behavior for the implementation and audience you actually support.

API reference

Props and Data

Configure Consent Manager using the contracts below. Read the documented options alongside the Source Definitions to understand which values your application supplies and which details the component owns. Start with a prop or helper, then follow its type link to inspect the declaration without leaving the page.

Props overview.

API reference
Your API, from source

Type cards are extracted from this checkout’s TypeScript source at build time. Props inherited through HTMLAttributes, Omit or variant helpers remain references in those declarations; their fields are not flattened here. Match the reference to your installed version, and check a package’s exports before writing an import type. A type exported by a source file is not necessarily re-exported by @kamod-ch/ui.

Component Props

Read each option with its owning component. The
marker identifies required fields verified in that declaration. A ? means a field can be omitted; it does not promise a fallback value. Existing documented defaults remain alongside the descriptions. For callbacks, check the argument and return types before connecting your own state or services.
@kamod-ch/ui/consent-manager70.1 KB min · 15.8 KB gzipSignals: direct@preact/signals

Data Type Reference

Expand a card to inspect and copy the exact declaration. The code header identifies its repository file; follow imported or inherited types in the Implementation Source when you need the complete dependency chain. Required-field summaries cover fields declared directly in that type. Source-only helpers and inferred schema outputs describe the local implementation, not additional props you can pass to every component.

ConsentManager Props

9 declared fields
ConsentManagerProps
Exported Source Declaration from ConsentManager.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentManagerProps before adapting it.
Required fields
categories, version

ConsentManagerCategory Props

2 declared fields
ConsentManagerCategoryProps
Exported Source Declaration from ConsentManagerCategory.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentManagerCategoryProps before adapting it.
Required fields
category

ConsentManagerContent Props

1 declared field
ConsentManagerContentProps
Exported Source Declaration from ConsentManagerContent.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentManagerContentProps before adapting it.
ConsentManagerSettingsProps
Exported Source Declaration from ConsentManagerSettings.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentManagerSettingsProps before adapting it.

ConsentManagerSummary Props

1 declared field
ConsentManagerSummaryProps
Exported Source Declaration from ConsentManagerSummary.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentManagerSummaryProps before adapting it.

ConsentManagerTrigger Props

2 declared fields
ConsentManagerTriggerProps
Exported Source Declaration from ConsentManagerTrigger.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentManagerTriggerProps before adapting it.

ConsentStorage

2 declared fields
ConsentStorage
Exported Source Declaration from consentStorage.ts. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentStorage before adapting it.
Required fields
get, set

ConsentState

3 declared fields
ConsentState
Exported Source Declaration from consentStorage.ts. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentState before adapting it.
Required fields
version, decidedAt, categories

ConsentCategoryShape

3 declared fields
ConsentCategoryShape
Exported Source Declaration from consentStorage.ts. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentCategoryShape before adapting it.
Required fields
id

ConsentCategory

6 declared fields
ConsentCategory
Exported Source Declaration from useConsent.ts. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentCategory before adapting it.
Required fields
id, title, description

ConsentManagerLabels

9 declared fields
ConsentManagerLabels
Exported Source Declaration from useConsent.ts. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentManagerLabels before adapting it.
Required fields
title, description, acceptAll, necessaryOnly, settings, settingsTitle, settingsDescription, save, back

ConsentManagerView

Declaration
ConsentManagerView
Exported Source Declaration from useConsent.ts. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentManagerView before adapting it.

ConsentContextValue

12 declared fields
ConsentContextValue
Exported Source Declaration from useConsent.ts. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentContextValue before adapting it.
Required fields
categories, labels, consent, draft, view, hasConsent, acceptAll, rejectAll, save, open, back, setCategory

ConsentApi

6 declared fields
ConsentApi
Exported Source Declaration from useConsent.ts. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentApi before adapting it.
Required fields
state, hasConsent, acceptAll, rejectAll, save, open

Take the Next Useful Step

You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.

Connect the Foundation

Return to Choose and Compose Components to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.

Build the Surrounding Screen

Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.

Make the Result Hold Up

Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.

Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.