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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthInstallation
Import the consent manager from @/components/kamod-ui/consent-manager. Labels default to English. Pass labels for another language.
pnpm add @kamod-ch/uiCopy 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 { 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 { ConsentManager } from "@kamod-ch/ui";Choose a complete composition from the examples below; required child components and props vary by pattern.
<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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthGerman
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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthGate 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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthAccessibility
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.
- Open with the keyboard, accept only necessary categories, reload, and confirm optional scripts stay unloaded.
- Try Escape and the overlay, then each action. Only a decision may close the dialog.
- 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.
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.
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
? 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.ConsentManager
ConsentManagerProps
| Prop / type | Description |
|---|---|
categories | Categories the person can accept. Required categories stay on.
|
children | Configure
|
labels | Replaces any of the default English labels.
|
onConsentChange | Called once after a decision is saved.
|
onOpenChange | Configure
|
open | Controlled open state. When omitted, the dialog opens until a valid decision exists.
|
storage | Persists the decision. Defaults to localStorage and ignores storage failures.
|
storageKey | Storage key. Default `kamod-consent`.
|
version | A new version invalidates a stored decision and shows the dialog again.
|
ConsentManagerCategory
ConsentManagerCategoryProps
| Prop / type | Description |
|---|---|
category | Configure
|
class | Configure
|
ConsentManagerContent
ConsentManagerContentProps
| Prop / type | Description |
|---|---|
class | Configure
|
ConsentManagerSettings
ConsentManagerSettingsProps
| Prop / type | Description |
|---|---|
class | Configure
|
ConsentManagerSummary
ConsentManagerSummaryProps
| Prop / type | Description |
|---|---|
class | Configure
|
ConsentManagerTrigger
ConsentManagerTriggerProps
| Prop / type | Description |
|---|---|
asChild | Configure
|
children | Configure
|
onClick | Configure
|
ref | Configure
|
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 fieldsConsentManagerPropsConsentManager.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentManagerProps before adapting it.categories, versionConsentManagerCategory Props
2 declared fieldsConsentManagerCategoryPropsConsentManagerCategory.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentManagerCategoryProps before adapting it.categoryConsentManagerContent Props
1 declared fieldConsentManagerContentPropsConsentManagerContent.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentManagerContentProps before adapting it.ConsentManagerSettings Props
1 declared fieldConsentManagerSettingsPropsConsentManagerSettings.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 fieldConsentManagerSummaryPropsConsentManagerSummary.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 fieldsConsentManagerTriggerPropsConsentManagerTrigger.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 fieldsConsentStorageconsentStorage.ts. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentStorage before adapting it.get, setConsentState
3 declared fieldsConsentStateconsentStorage.ts. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentState before adapting it.version, decidedAt, categoriesConsentCategoryShape
3 declared fieldsConsentCategoryShapeconsentStorage.ts. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentCategoryShape before adapting it.idConsentCategory
6 declared fieldsConsentCategoryuseConsent.ts. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentCategory before adapting it.id, title, descriptionConsentManagerLabels
9 declared fieldsConsentManagerLabelsuseConsent.ts. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentManagerLabels before adapting it.title, description, acceptAll, necessaryOnly, settings, settingsTitle, settingsDescription, save, backConsentManagerView
DeclarationConsentManagerViewuseConsent.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 fieldsConsentContextValueuseConsent.ts. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentContextValue before adapting it.categories, labels, consent, draft, view, hasConsent, acceptAll, rejectAll, save, open, back, setCategoryConsentApi
6 declared fieldsConsentApiuseConsent.ts. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ConsentApi before adapting it.state, hasConsent, acceptAll, rejectAll, save, openYou 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.