@c15t/nextjs 2.1.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +155 -0
- package/README.md +31 -15
- package/client/components/integrations.js +3 -0
- package/dist/components/integrations/index.cjs +1 -0
- package/dist/components/integrations/index.js +1 -0
- package/dist/headless.cjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/libs/browser-initial-data.cjs +1 -1
- package/dist/libs/initial-data.cjs +1 -1
- package/dist/styles.tw3.css +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.js +1 -1
- package/dist-types/components/integrations/index.d.ts +1 -0
- package/dist-types/libs/browser-initial-data.d.ts +1 -1
- package/dist-types/version.d.ts +1 -1
- package/docs/README.md +155 -73
- package/docs/{building-headless-components.md → frameworks/next/building-headless-components.md} +3 -1
- package/docs/{callbacks.md → frameworks/next/callbacks.md} +3 -1
- package/docs/{components → frameworks/next/components}/consent-banner.md +10 -21
- package/docs/{components → frameworks/next/components}/consent-dialog-link.md +8 -5
- package/docs/frameworks/next/components/consent-dialog-trigger.md +202 -0
- package/docs/{components → frameworks/next/components}/consent-dialog.md +7 -15
- package/docs/frameworks/next/components/consent-manager-provider.md +327 -0
- package/docs/{components → frameworks/next/components}/consent-widget.md +8 -6
- package/docs/{components → frameworks/next/components}/dev-tools.md +9 -6
- package/docs/{components → frameworks/next/components}/frame.md +8 -9
- package/docs/{concepts → frameworks/next/concepts}/client-modes.md +4 -2
- package/docs/{concepts → frameworks/next/concepts}/consent-categories.md +1 -0
- package/docs/{concepts → frameworks/next/concepts}/consent-models.md +1 -0
- package/docs/{concepts → frameworks/next/concepts}/cookie-management.md +3 -3
- package/docs/{concepts → frameworks/next/concepts}/glossary.md +1 -0
- package/docs/{concepts → frameworks/next/concepts}/initialization-flow.md +1 -0
- package/docs/{concepts → frameworks/next/concepts}/policy-packs.md +1 -0
- package/docs/{headless.md → frameworks/next/headless.md} +3 -1
- package/docs/{hooks → frameworks/next/hooks}/use-color-scheme.md +1 -0
- package/docs/{hooks → frameworks/next/hooks}/use-consent-manager/checking-consent.md +3 -1
- package/docs/{hooks → frameworks/next/hooks}/use-consent-manager/location-info.md +3 -1
- package/docs/frameworks/next/hooks/use-consent-manager/overview.md +185 -0
- package/docs/{hooks → frameworks/next/hooks}/use-consent-manager/setting-consent.md +3 -1
- package/docs/{hooks → frameworks/next/hooks}/use-draggable.md +3 -1
- package/docs/{hooks → frameworks/next/hooks}/use-focus-trap.md +1 -0
- package/docs/{hooks → frameworks/next/hooks}/use-reduced-motion.md +3 -1
- package/docs/{hooks → frameworks/next/hooks}/use-ssr-status.md +6 -5
- package/docs/{hooks → frameworks/next/hooks}/use-text-direction.md +1 -0
- package/docs/frameworks/next/hooks/use-translations.md +55 -0
- package/docs/{iab → frameworks/next/iab}/consent-banner.md +9 -12
- package/docs/{iab → frameworks/next/iab}/consent-dialog.md +9 -14
- package/docs/{iab → frameworks/next/iab}/overview.md +4 -2
- package/docs/{iab → frameworks/next/iab}/use-gvl-data.md +3 -2
- package/docs/{iframe-blocking.md → frameworks/next/iframe-blocking.md} +8 -9
- package/docs/{internationalization.md → frameworks/next/internationalization.md} +13 -3
- package/docs/{network-blocker.md → frameworks/next/network-blocker.md} +13 -51
- package/docs/{optimization.md → frameworks/next/optimization.md} +5 -4
- package/docs/{policy-packs.md → frameworks/next/policy-packs.md} +3 -1
- package/docs/{quickstart.md → frameworks/next/quickstart.md} +26 -42
- package/docs/{script-loader.md → frameworks/next/script-loader.md} +72 -90
- package/docs/{server-side.md → frameworks/next/server-side.md} +12 -15
- package/docs/{styling → frameworks/next/styling}/classnames.md +3 -1
- package/docs/{styling → frameworks/next/styling}/color-scheme.md +3 -1
- package/docs/frameworks/next/styling/css-variables.md +53 -0
- package/docs/frameworks/next/styling/overview.md +299 -0
- package/docs/frameworks/next/styling/slots.md +94 -0
- package/docs/{styling → frameworks/next/styling}/tailwind.md +3 -1
- package/docs/frameworks/next/styling/tokens.md +156 -0
- package/docs/{troubleshooting.md → frameworks/next/troubleshooting.md} +3 -1
- package/docs/integrations/adobe-analytics.md +160 -0
- package/docs/integrations/ahrefs-analytics.md +15 -82
- package/docs/integrations/amplitude.md +230 -0
- package/docs/integrations/building-integrations.md +15 -181
- package/docs/integrations/clearbit.md +130 -0
- package/docs/integrations/cloudflare-web-analytics.md +15 -83
- package/docs/integrations/crisp.md +13 -87
- package/docs/integrations/databuddy.md +16 -85
- package/docs/integrations/fathom-analytics.md +15 -86
- package/docs/integrations/google-maps.md +263 -0
- package/docs/integrations/google-tag-manager.md +18 -86
- package/docs/integrations/google-tag.md +15 -84
- package/docs/integrations/heap.md +219 -0
- package/docs/integrations/hightouch.md +199 -0
- package/docs/integrations/hotjar.md +15 -83
- package/docs/integrations/intercom.md +13 -83
- package/docs/integrations/linkedin-insights.md +15 -82
- package/docs/integrations/logrocket.md +175 -0
- package/docs/integrations/matomo-analytics.md +13 -88
- package/docs/integrations/meta-pixel.md +33 -316
- package/docs/integrations/microsoft-clarity.md +15 -83
- package/docs/integrations/microsoft-uet.md +16 -83
- package/docs/integrations/mixpanel-analytics.md +15 -83
- package/docs/integrations/overview.md +55 -6
- package/docs/integrations/pirsch.md +142 -0
- package/docs/integrations/plausible-analytics.md +14 -97
- package/docs/integrations/posthog.md +26 -98
- package/docs/integrations/promptwatch.md +16 -82
- package/docs/integrations/reddit-pixel.md +27 -122
- package/docs/integrations/rudderstack.md +271 -0
- package/docs/integrations/rybbit-analytics.md +15 -94
- package/docs/integrations/segment.md +15 -82
- package/docs/integrations/snapchat-pixel.md +21 -102
- package/docs/integrations/tiktok-pixel.md +13 -81
- package/docs/integrations/umami-analytics.md +16 -88
- package/docs/integrations/vercel-analytics.md +13 -85
- package/docs/integrations/x-pixel.md +27 -102
- package/docs/integrations/youtube.md +193 -0
- package/docs/shared/concepts/client-modes.md +103 -0
- package/docs/shared/concepts/consent-categories.md +41 -0
- package/docs/shared/concepts/consent-models.md +72 -0
- package/docs/shared/concepts/cookie-management.md +88 -0
- package/docs/shared/concepts/glossary.md +24 -0
- package/docs/shared/concepts/initialization-flow.md +105 -0
- package/docs/shared/concepts/policy-packs.md +225 -0
- package/docs/shared/react/components/consent-banner.md +242 -0
- package/docs/shared/react/components/consent-dialog-link.md +45 -0
- package/docs/shared/react/components/consent-dialog-trigger.md +185 -0
- package/docs/shared/react/components/consent-dialog.md +119 -0
- package/docs/shared/react/components/consent-manager-provider.md +225 -0
- package/docs/shared/react/components/consent-widget.md +121 -0
- package/docs/shared/react/components/dev-tools.md +81 -0
- package/docs/shared/react/components/frame.md +52 -0
- package/docs/shared/react/guides/building-headless-components.md +110 -0
- package/docs/shared/react/guides/callbacks.md +89 -0
- package/docs/shared/react/guides/headless.md +31 -0
- package/docs/shared/react/guides/iframe-blocking.md +65 -0
- package/docs/shared/react/guides/internationalization.md +123 -0
- package/docs/shared/react/guides/network-blocker.md +72 -0
- package/docs/shared/react/guides/optimization.md +44 -0
- package/docs/shared/react/guides/policy-packs.md +173 -0
- package/docs/shared/react/guides/script-loader.md +311 -0
- package/docs/shared/react/hooks/use-color-scheme.md +31 -0
- package/docs/shared/react/hooks/use-consent-manager/checking-consent.md +95 -0
- package/docs/shared/react/hooks/use-consent-manager/location-info.md +96 -0
- package/docs/shared/react/hooks/use-consent-manager/overview.md +74 -0
- package/docs/shared/react/hooks/use-consent-manager/setting-consent.md +93 -0
- package/docs/shared/react/hooks/use-draggable.md +30 -0
- package/docs/shared/react/hooks/use-focus-trap.md +20 -0
- package/docs/shared/react/hooks/use-reduced-motion.md +33 -0
- package/docs/shared/react/hooks/use-ssr-status.md +16 -0
- package/docs/shared/react/hooks/use-text-direction.md +38 -0
- package/docs/shared/react/hooks/use-translations.md +15 -0
- package/docs/shared/react/iab/consent-banner.md +60 -0
- package/docs/shared/react/iab/consent-dialog.md +76 -0
- package/docs/shared/react/iab/overview.md +80 -0
- package/docs/shared/react/iab/use-gvl-data.md +21 -0
- package/docs/shared/react/styling/classnames.md +93 -0
- package/docs/shared/react/styling/color-scheme.md +35 -0
- package/docs/shared/react/styling/css-variables.md +53 -0
- package/docs/shared/react/styling/overview.md +261 -0
- package/docs/shared/react/styling/slots.md +93 -0
- package/docs/shared/react/styling/stylesheet-entrypoint.md +8 -0
- package/docs/shared/react/styling/tailwind.md +88 -0
- package/docs/shared/react/styling/tokens.md +155 -0
- package/docs/shared/troubleshooting.md +82 -0
- package/package.json +19 -10
- package/readme.json +14 -8
- package/docs/ai-agents.md +0 -111
- package/docs/components/consent-dialog-trigger.md +0 -103
- package/docs/components/consent-manager-provider.md +0 -425
- package/docs/hooks/use-consent-manager/overview.md +0 -420
- package/docs/hooks/use-translations.md +0 -118
- package/docs/styling/css-variables.md +0 -92
- package/docs/styling/overview.md +0 -457
- package/docs/styling/slots.md +0 -128
- package/docs/styling/tokens.md +0 -216
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Consent Dialog
|
|
3
|
+
description: Reference page for consent dialog.
|
|
4
|
+
group: reference
|
|
5
|
+
---
|
|
6
|
+
`ConsentDialog` is a modal that shows toggles for each consent category. In **opt-in jurisdictions**, it typically opens when users click "Customize" on `ConsentBanner`. It can also be controlled programmatically for use on settings pages regardless of jurisdiction.
|
|
7
|
+
|
|
8
|
+
## Floating Trigger
|
|
9
|
+
|
|
10
|
+
Add a floating button that lets users re-open the dialog after dismissing the banner:
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
{/* Default trigger */}
|
|
14
|
+
<ConsentDialog showTrigger />
|
|
15
|
+
|
|
16
|
+
{/* Custom trigger */}
|
|
17
|
+
<ConsentDialog
|
|
18
|
+
showTrigger={{
|
|
19
|
+
icon: 'settings',
|
|
20
|
+
defaultPosition: 'bottom-left',
|
|
21
|
+
showWhen: 'after-consent',
|
|
22
|
+
size: 'sm',
|
|
23
|
+
}}
|
|
24
|
+
/>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Branding
|
|
28
|
+
|
|
29
|
+
Hide the c15t branding tag:
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
<ConsentDialog hideBranding />
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Styling First
|
|
36
|
+
|
|
37
|
+
> ℹ️ **Info:**
|
|
38
|
+
> If you are only changing visuals, stay with the stock dialog and use the theme system first. Start with tokens and slots such as consentDialogCard, consentWidgetFooter, and consentDialogTag. See Styling Overview.
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
<ConsentManagerProvider
|
|
42
|
+
options={{
|
|
43
|
+
theme: {
|
|
44
|
+
colors: {
|
|
45
|
+
surface: '#fffdf8',
|
|
46
|
+
surfaceHover: '#f6f3ee',
|
|
47
|
+
},
|
|
48
|
+
slots: {
|
|
49
|
+
consentDialogCard: 'rounded-[32px] shadow-xl',
|
|
50
|
+
consentDialogHeader: 'gap-3',
|
|
51
|
+
consentWidgetFooter: 'gap-3 pt-6',
|
|
52
|
+
consentDialogTag: 'shadow-none',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
<ConsentDialog />
|
|
58
|
+
</ConsentManagerProvider>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Dialog copy should be changed through `ConsentManagerProvider.options.i18n`, not by rebuilding the dialog structure.
|
|
62
|
+
|
|
63
|
+
## Advanced: Compound Components
|
|
64
|
+
|
|
65
|
+
Use compound components only when you need custom dialog markup while still keeping c15t primitives and policy-aware footer actions:
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
<ConsentDialog.Root>
|
|
69
|
+
<ConsentDialog.Overlay />
|
|
70
|
+
<ConsentDialog.Card>
|
|
71
|
+
<ConsentDialog.Header>
|
|
72
|
+
<ConsentDialog.HeaderTitle />
|
|
73
|
+
<ConsentDialog.HeaderDescription />
|
|
74
|
+
</ConsentDialog.Header>
|
|
75
|
+
<ConsentDialog.Content>
|
|
76
|
+
<ConsentWidget.Root>
|
|
77
|
+
<ConsentWidget.Accordion type="single">
|
|
78
|
+
<ConsentWidget.AccordionItems />
|
|
79
|
+
</ConsentWidget.Accordion>
|
|
80
|
+
<ConsentWidget.PolicyActions />
|
|
81
|
+
</ConsentWidget.Root>
|
|
82
|
+
</ConsentDialog.Content>
|
|
83
|
+
<ConsentDialog.Footer />
|
|
84
|
+
</ConsentDialog.Card>
|
|
85
|
+
</ConsentDialog.Root>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
* `ConsentDialog.Root` — Portal container with focus trap, scroll lock, and animation
|
|
89
|
+
* `ConsentDialog.Card` — Main dialog card
|
|
90
|
+
* `ConsentDialog.Header` — Contains title and description
|
|
91
|
+
* `ConsentDialog.HeaderTitle` — Dialog title
|
|
92
|
+
* `ConsentDialog.HeaderDescription` — Description with optional `legalLinks`
|
|
93
|
+
* `ConsentDialog.Content` — Main content area (typically contains `ConsentWidget`)
|
|
94
|
+
* `ConsentDialog.Footer` — Footer with optional branding (`hideBranding` prop)
|
|
95
|
+
* `ConsentDialog.Overlay` — Backdrop overlay
|
|
96
|
+
* `ConsentWidget.PolicyActions` — Renders policy-aware grouped dialog actions
|
|
97
|
+
|
|
98
|
+
For a quick pre-composed layout, use the shorthand card:
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
<ConsentDialog.Root>
|
|
102
|
+
<ConsentDialog.ConsentCustomizationCard />
|
|
103
|
+
</ConsentDialog.Root>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`ConsentWidget.PolicyActions` uses stock c15t widget buttons and translations by default. Pass `renderAction` only when you need to customize the action mapping, and return stock widget button compounds if you want to preserve built-in behavior and copy.
|
|
107
|
+
|
|
108
|
+
For fully manual control over dialog action rendering, use `useHeadlessConsentUI()` and map `dialog.actionGroups` yourself.
|
|
109
|
+
|
|
110
|
+
If the stock dialog structure still works, prefer tokens, slots, and provider configuration instead.
|
|
111
|
+
|
|
112
|
+
## Props
|
|
113
|
+
|
|
114
|
+
|Property|Value|
|
|
115
|
+
|:--|:--|
|
|
116
|
+
|Type Name|\`ConsentDialogProps\`|
|
|
117
|
+
|Source Path|\`./packages/react/src/components/consent-dialog/consent-dialog.tsx\`|
|
|
118
|
+
|
|
119
|
+
\*ExtractedTypeTable: Could not extract "ConsentDialogProps" from "./packages/react/src/components/consent-dialog/consent-dialog.tsx" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Consent Manager Provider
|
|
3
|
+
description: Reference page for consent manager provider.
|
|
4
|
+
group: reference
|
|
5
|
+
---
|
|
6
|
+
`ConsentManagerProvider` is the root component for the c15t consent system. It initializes the consent store, detects the user's jurisdiction, resolves translations, and provides consent state to all child components via React context.
|
|
7
|
+
|
|
8
|
+
Every other c15t component and hook must be rendered inside this provider.
|
|
9
|
+
|
|
10
|
+
## Options Reference
|
|
11
|
+
|
|
12
|
+
|Property|Value|
|
|
13
|
+
|:--|:--|
|
|
14
|
+
|Type Name|\`CommonInlineStoreOptions\`|
|
|
15
|
+
|Source Path|\`./packages/ui/src/theme/options.ts\`|
|
|
16
|
+
|
|
17
|
+
\*ExtractedTypeTable: Could not extract "CommonInlineStoreOptions" from "./packages/ui/src/theme/options.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
18
|
+
|
|
19
|
+
|Property|Value|
|
|
20
|
+
|:--|:--|
|
|
21
|
+
|Type Name|\`ConsentManagerContentOptions\`|
|
|
22
|
+
|Source Path|\`./packages/ui/src/theme/options.ts\`|
|
|
23
|
+
|
|
24
|
+
\*ExtractedTypeTable: Could not extract "ConsentManagerContentOptions" from "./packages/ui/src/theme/options.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
25
|
+
|
|
26
|
+
|Property|Value|
|
|
27
|
+
|:--|:--|
|
|
28
|
+
|Type Name|\`UIOptions\`|
|
|
29
|
+
|Source Path|\`./packages/ui/src/theme/types.ts\`|
|
|
30
|
+
|
|
31
|
+
\*ExtractedTypeTable: Could not extract "UIOptions" from "./packages/ui/src/theme/types.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
32
|
+
|
|
33
|
+
## Content Security Policy
|
|
34
|
+
|
|
35
|
+
c15t injects a `<style id="c15t-theme">` element for your theme tokens, and the script loader injects a `<script>` element per consented vendor. Under a nonce-based Content Security Policy, both are blocked unless they carry your nonce.
|
|
36
|
+
|
|
37
|
+
Pass it once through the `nonce` option and c15t applies it to everything it injects:
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
<ConsentManagerProvider
|
|
41
|
+
options={{
|
|
42
|
+
mode: 'offline',
|
|
43
|
+
nonce: yourRequestNonce,
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
{children}
|
|
47
|
+
</ConsentManagerProvider>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
A `nonce` set on an individual script definition still wins, so you can override a single vendor without changing the provider.
|
|
51
|
+
|
|
52
|
+
> 📝 **Note:**
|
|
53
|
+
> Browsers hide the nonce content attribute once a policy is active. Inspecting the element shows no nonce="", but element.nonce still returns the value — this is expected and not a sign that c15t dropped it.
|
|
54
|
+
|
|
55
|
+
### Inline style attributes
|
|
56
|
+
|
|
57
|
+
The `nonce` option covers the elements c15t injects. It cannot cover inline `style="..."` attributes, which several components rely on — a nonce never authorizes a style attribute, because nonces apply to elements only.
|
|
58
|
+
|
|
59
|
+
Style attributes are governed by `style-src-attr`, and when that directive is absent CSP falls back to `style-src`. A nonce-based style policy therefore blocks them:
|
|
60
|
+
|
|
61
|
+
```http
|
|
62
|
+
style-src 'self' 'nonce-abc123';
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
To keep the nonce requirement for stylesheets while still allowing style attributes, set `style-src-attr` explicitly:
|
|
66
|
+
|
|
67
|
+
```http
|
|
68
|
+
style-src 'self' 'nonce-abc123';
|
|
69
|
+
style-src-attr 'unsafe-inline';
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
> ⚠️ **Warning:**
|
|
73
|
+
> 'unsafe-inline' on style-src-attr permits any inline style attribute on the page. That is weaker than a nonce, but far narrower than replacing your nonce-based style-src with 'unsafe-inline', which would additionally authorize arbitrary injected \<style> elements. Note that adding 'unsafe-inline' alongside a nonce achieves nothing — a directive that specifies a nonce ignores it. If your threat model does not allow this, expect components that use inline styles to render unstyled.
|
|
74
|
+
|
|
75
|
+
## Legal Links
|
|
76
|
+
|
|
77
|
+
`legalLinks` defines the URLs shown in consent UI text (banner, dialog, and widget where applicable).
|
|
78
|
+
Configure only the links you want to expose.
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
<ConsentManagerProvider
|
|
82
|
+
options={{
|
|
83
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
84
|
+
legalLinks: {
|
|
85
|
+
privacyPolicy: {
|
|
86
|
+
href: '/privacy',
|
|
87
|
+
target: '_self',
|
|
88
|
+
},
|
|
89
|
+
cookiePolicy: {
|
|
90
|
+
href: '/cookies',
|
|
91
|
+
target: '_self',
|
|
92
|
+
},
|
|
93
|
+
termsOfService: {
|
|
94
|
+
href: 'https://example.com/terms',
|
|
95
|
+
target: '_blank',
|
|
96
|
+
rel: 'noopener noreferrer',
|
|
97
|
+
label: 'Terms of Service',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
}}
|
|
101
|
+
>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Notes:
|
|
105
|
+
|
|
106
|
+
* Omitting a key (for example `termsOfService`) hides that link.
|
|
107
|
+
* `label` overrides the translated text for that single link.
|
|
108
|
+
* Use `_self` for internal pages and `_blank` + `rel="noopener noreferrer"` for external pages.
|
|
109
|
+
* Control which of the configured links render in each component via the component's `legalLinks` prop.
|
|
110
|
+
|
|
111
|
+
## Overrides
|
|
112
|
+
|
|
113
|
+
`overrides` lets you force location/language signals instead of browser or network detection.
|
|
114
|
+
This is useful for QA, local development, and preview environments.
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
<ConsentManagerProvider
|
|
118
|
+
options={{
|
|
119
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
120
|
+
overrides: {
|
|
121
|
+
country: 'DE',
|
|
122
|
+
region: 'BY',
|
|
123
|
+
language: 'de-DE',
|
|
124
|
+
},
|
|
125
|
+
}}
|
|
126
|
+
>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
You can also override Global Privacy Control (GPC) behavior during testing:
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
<ConsentManagerProvider
|
|
133
|
+
options={{
|
|
134
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
135
|
+
overrides: {
|
|
136
|
+
gpc: true,
|
|
137
|
+
},
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
> ⚠️ **Warning:**
|
|
143
|
+
> Treat overrides as an environment/testing tool. Avoid hard-coding production overrides unless that behavior is intentional for your deployment.
|
|
144
|
+
|
|
145
|
+
## Policy Packs
|
|
146
|
+
|
|
147
|
+
In hosted mode (recommended), the backend resolves the correct policy automatically — no frontend policy config needed:
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
<ConsentManagerProvider
|
|
151
|
+
options={{
|
|
152
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
153
|
+
}}
|
|
154
|
+
>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Fallback: Offline Policies
|
|
158
|
+
|
|
159
|
+
When no backend is available, `ConsentManagerProvider` accepts `offlinePolicy.policyPacks` for local policy resolution during development, testing, previews, or temporary backend outages:
|
|
160
|
+
|
|
161
|
+
```tsx
|
|
162
|
+
<ConsentManagerProvider
|
|
163
|
+
options={{
|
|
164
|
+
mode: 'offline',
|
|
165
|
+
offlinePolicy: {
|
|
166
|
+
i18n: {
|
|
167
|
+
defaultProfile: 'default',
|
|
168
|
+
messages: {
|
|
169
|
+
default: {
|
|
170
|
+
translations: {
|
|
171
|
+
en: { cookieBanner: { title: 'Privacy choices' } },
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
qc: {
|
|
175
|
+
fallbackLanguage: 'fr',
|
|
176
|
+
translations: {
|
|
177
|
+
en: { cookieBanner: { title: 'Quebec Privacy Settings' } },
|
|
178
|
+
fr: { cookieBanner: { title: 'Paramètres de confidentialité du Québec' } },
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
policyPacks: [
|
|
184
|
+
{
|
|
185
|
+
id: 'qc_opt_in',
|
|
186
|
+
match: { regions: [{ country: 'CA', region: 'QC' }] },
|
|
187
|
+
i18n: { messageProfile: 'qc' },
|
|
188
|
+
consent: { model: 'opt-in', expiryDays: 365 },
|
|
189
|
+
ui: { mode: 'banner' },
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
id: 'default_world',
|
|
193
|
+
match: { isDefault: true },
|
|
194
|
+
consent: { model: 'none' },
|
|
195
|
+
ui: { mode: 'none' },
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
},
|
|
199
|
+
overrides: {
|
|
200
|
+
country: 'CA',
|
|
201
|
+
region: 'QC',
|
|
202
|
+
},
|
|
203
|
+
}}
|
|
204
|
+
>
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Notes:
|
|
208
|
+
|
|
209
|
+
* `offlinePolicy` is only used in `offline` mode.
|
|
210
|
+
* Treat offline policies as a development/testing tool or resilience fallback, not the primary production source of truth.
|
|
211
|
+
* `offlinePolicy.i18n` lets offline mode mirror hosted `messageProfile` and profile-local `fallbackLanguage` behavior.
|
|
212
|
+
* Omitting `offlinePolicy.policyPacks` uses the built-in synthetic opt-in fallback banner. Hosted network fallback uses the same opt-in banner.
|
|
213
|
+
* `offlinePolicy: { policyPacks: [] }` is explicit no-banner mode.
|
|
214
|
+
* In hosted mode, backend `policyPacks` remain the source of truth — frontend offline policies never override a live backend decision.
|
|
215
|
+
|
|
216
|
+
Read the full guide at [Policy Packs](/docs/frameworks/react/policy-packs) and the conceptual model at [Policy Packs Concept](/docs/frameworks/react/concepts/policy-packs).
|
|
217
|
+
|
|
218
|
+
## Props
|
|
219
|
+
|
|
220
|
+
|Property|Value|
|
|
221
|
+
|:--|:--|
|
|
222
|
+
|Type Name|\`ConsentManagerProviderProps\`|
|
|
223
|
+
|Source Path|\`./packages/react/src/types/consent-manager.ts\`|
|
|
224
|
+
|
|
225
|
+
\*ExtractedTypeTable: Could not extract "ConsentManagerProviderProps" from "./packages/react/src/types/consent-manager.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Consent Widget
|
|
3
|
+
description: Reference page for consent widget.
|
|
4
|
+
group: reference
|
|
5
|
+
---
|
|
6
|
+
`ConsentWidget` is a standalone, inline consent management widget. Unlike `ConsentDialog` (which is a modal), the widget embeds directly in your page layout - ideal for privacy settings pages, account preferences, or any page where users should be able to manage consent without a modal overlay.
|
|
7
|
+
|
|
8
|
+
## Configuration
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
<ConsentWidget
|
|
12
|
+
hideBranding
|
|
13
|
+
legalLinks={['privacyPolicy', 'cookiePolicy']}
|
|
14
|
+
noStyle={false}
|
|
15
|
+
disableAnimation={false}
|
|
16
|
+
/>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Accordion Behavior
|
|
20
|
+
|
|
21
|
+
Each consent category is rendered as an expandable accordion item. Clicking the category header expands it to show a description and any associated services. Users can toggle individual categories on or off using the switch control. The `necessary` category is always enabled and cannot be toggled.
|
|
22
|
+
|
|
23
|
+
## Styling First
|
|
24
|
+
|
|
25
|
+
> ℹ️ **Info:**
|
|
26
|
+
> Most widget customization should stay in the stock component. Use theme tokens and slots such as consentWidgetAccordion, consentWidgetFooter, consentWidgetFooterSubGroup, and toggle before reaching for compound components. See Styling Overview.
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
<ConsentManagerProvider
|
|
30
|
+
options={{
|
|
31
|
+
theme: {
|
|
32
|
+
colors: {
|
|
33
|
+
surface: '#fffdf8',
|
|
34
|
+
surfaceHover: '#f6f3ee',
|
|
35
|
+
},
|
|
36
|
+
slots: {
|
|
37
|
+
consentWidgetAccordion: 'rounded-3xl border border-black/10',
|
|
38
|
+
consentWidgetFooter: 'border-t border-black/10 px-6',
|
|
39
|
+
consentWidgetFooterSubGroup: 'gap-3',
|
|
40
|
+
toggle: 'shadow-sm',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
<ConsentWidget />
|
|
46
|
+
</ConsentManagerProvider>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Use `consentWidgetFooter` for styling the whole action area, such as border and padding. Use `consentWidgetFooterSubGroup` for spacing or alignment inside nested button groups.
|
|
50
|
+
|
|
51
|
+
Widget copy should be changed through `ConsentManagerProvider.options.i18n` so the inline UI stays aligned with the rest of the consent experience.
|
|
52
|
+
|
|
53
|
+
## Advanced: Compound Components
|
|
54
|
+
|
|
55
|
+
Use compound components only when you need to rearrange the widget's existing primitives while keeping policy-aware action grouping:
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
<ConsentWidget.Root>
|
|
59
|
+
<ConsentWidget.Accordion type="multiple">
|
|
60
|
+
<ConsentWidget.AccordionItems />
|
|
61
|
+
</ConsentWidget.Accordion>
|
|
62
|
+
<ConsentWidget.PolicyActions />
|
|
63
|
+
</ConsentWidget.Root>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
* `ConsentWidget.Root` — Theme context provider
|
|
67
|
+
* `ConsentWidget.Accordion` — Radix-based accordion root
|
|
68
|
+
* `ConsentWidget.AccordionItems` — Auto-generates toggle items from consent config
|
|
69
|
+
* `ConsentWidget.AccordionItem` — Individual category item
|
|
70
|
+
* `ConsentWidget.AccordionTrigger` — Clickable header for each item
|
|
71
|
+
* `ConsentWidget.AccordionContent` — Collapsible content area
|
|
72
|
+
* `ConsentWidget.AccordionArrow` — Expand/collapse indicator
|
|
73
|
+
* `ConsentWidget.Switch` — Category toggle switch
|
|
74
|
+
* `ConsentWidget.PolicyActions` — Renders grouped policy-aware actions
|
|
75
|
+
* `ConsentWidget.Footer` — Footer container
|
|
76
|
+
* `ConsentWidget.FooterSubGroup` — Groups related buttons
|
|
77
|
+
* `ConsentWidget.AcceptAllButton` — Accepts all consent
|
|
78
|
+
* `ConsentWidget.RejectButton` — Rejects all consent
|
|
79
|
+
* `ConsentWidget.SaveButton` — Saves custom selections
|
|
80
|
+
|
|
81
|
+
## Using `renderAction` with c15t Defaults
|
|
82
|
+
|
|
83
|
+
`ConsentWidget.PolicyActions` renders stock c15t buttons and translations by default.
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
<ConsentWidget.PolicyActions />
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`renderAction` is optional. Return the stock button compounds when you want custom mapping while preserving built-in c15t behavior and copy:
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
<ConsentWidget.PolicyActions
|
|
93
|
+
renderAction={(action, props) => {
|
|
94
|
+
const { key, ...buttonProps } = props
|
|
95
|
+
|
|
96
|
+
switch (action) {
|
|
97
|
+
case 'accept':
|
|
98
|
+
return <ConsentWidget.AcceptAllButton key={key} {...buttonProps} />
|
|
99
|
+
case 'reject':
|
|
100
|
+
return <ConsentWidget.RejectButton key={key} {...buttonProps} />
|
|
101
|
+
case 'customize':
|
|
102
|
+
return <ConsentWidget.SaveButton key={key} {...buttonProps} />
|
|
103
|
+
}
|
|
104
|
+
}}
|
|
105
|
+
/>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`renderAction` is still meant for stock button compounds. If you want completely custom button elements and handlers, use `useHeadlessConsentUI()` and render `dialog.actionGroups` manually instead of `ConsentWidget.PolicyActions`.
|
|
109
|
+
|
|
110
|
+
For a fixed footer layout, render `ConsentWidget.Footer` and `ConsentWidget.FooterSubGroup` manually instead of using `ConsentWidget.PolicyActions`.
|
|
111
|
+
|
|
112
|
+
If the stock widget structure is already correct, stay with tokens and slots instead of rebuilding the layout.
|
|
113
|
+
|
|
114
|
+
## Props
|
|
115
|
+
|
|
116
|
+
|Property|Value|
|
|
117
|
+
|:--|:--|
|
|
118
|
+
|Type Name|\`ConsentWidgetProps\`|
|
|
119
|
+
|Source Path|\`./packages/react/src/components/consent-widget/types.ts\`|
|
|
120
|
+
|
|
121
|
+
\*ExtractedTypeTable: Could not extract "ConsentWidgetProps" from "./packages/react/src/components/consent-widget/types.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Dev Tools
|
|
3
|
+
description: Reference page for dev tools.
|
|
4
|
+
group: reference
|
|
5
|
+
---
|
|
6
|
+
`DevTools` is a floating panel that shows the internal state of the consent manager. Use it during development to inspect consent values, geolocation results, loaded scripts, and debug consent flows. Also exported as `C15TDevTools` if you need to avoid naming conflicts with other devtools.
|
|
7
|
+
|
|
8
|
+
> ⚠️ **Warning:**
|
|
9
|
+
> DevTools should only be included in development builds. The component renders nothing to the React tree - it injects directly into document.body.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
DevTools lives in a separate package to keep it out of production bundles:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
bun add -D @c15t/dev-tools
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Configuration
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
<DevTools
|
|
23
|
+
position="bottom-right" // 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
|
|
24
|
+
defaultOpen={false} // Start with panel open
|
|
25
|
+
namespace="c15tStore" // Store namespace to connect to
|
|
26
|
+
disabled={false} // Disable without removing from tree
|
|
27
|
+
/>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Panels
|
|
31
|
+
|
|
32
|
+
|Panel|What it shows|
|
|
33
|
+
|--|--|
|
|
34
|
+
|**Consents**|Current consent state for all categories|
|
|
35
|
+
|**Location**|Detected jurisdiction, country, region, and consent model|
|
|
36
|
+
|**Scripts**|Configured scripts and their load status|
|
|
37
|
+
|**IAB**|IAB TCF state (when enabled) - TC string, vendor consents, purposes|
|
|
38
|
+
|**Events**|Timeline of consent events and state changes|
|
|
39
|
+
|**Actions**|Buttons to trigger consent actions (accept all, reject all, reset)|
|
|
40
|
+
|
|
41
|
+
## TanStack Devtools
|
|
42
|
+
|
|
43
|
+
`@c15t/dev-tools/tanstack` exposes a panel component and plugin factory that match TanStack Devtools' plugin API, so c15t can sit beside Query and Router without a custom mount adapter:
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import * as React from 'react';
|
|
47
|
+
import { useRouter } from '@tanstack/react-router';
|
|
48
|
+
import { TanStackDevtools } from '@tanstack/react-devtools';
|
|
49
|
+
import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools';
|
|
50
|
+
import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools';
|
|
51
|
+
import { c15tDevtools } from '@c15t/dev-tools/tanstack';
|
|
52
|
+
|
|
53
|
+
export function AppDevtools() {
|
|
54
|
+
const router = useRouter();
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<TanStackDevtools
|
|
58
|
+
plugins={[
|
|
59
|
+
{
|
|
60
|
+
name: 'TanStack Query',
|
|
61
|
+
render: <ReactQueryDevtoolsPanel />,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'TanStack Router',
|
|
65
|
+
render: <TanStackRouterDevtoolsPanel router={router} />,
|
|
66
|
+
},
|
|
67
|
+
c15tDevtools(),
|
|
68
|
+
]}
|
|
69
|
+
/>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Props
|
|
75
|
+
|
|
76
|
+
|Property|Value|
|
|
77
|
+
|:--|:--|
|
|
78
|
+
|Type Name|\`C15TDevToolsProps\`|
|
|
79
|
+
|Source Path|\`./packages/dev-tools/src/react.ts\`|
|
|
80
|
+
|
|
81
|
+
\*ExtractedTypeTable: Could not extract "C15TDevToolsProps" from "./packages/dev-tools/src/react.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Frame
|
|
3
|
+
description: Reference page for frame.
|
|
4
|
+
group: reference
|
|
5
|
+
---
|
|
6
|
+
`Frame` conditionally renders its children based on consent state. When consent for the specified category is not granted, a placeholder is shown instead. Children are not mounted at all until consent is given, preventing any network requests or script execution.
|
|
7
|
+
|
|
8
|
+
## Custom Placeholder
|
|
9
|
+
|
|
10
|
+
Replace the default placeholder:
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
<Frame
|
|
14
|
+
category="experience"
|
|
15
|
+
placeholder={
|
|
16
|
+
<div className="rounded-lg border p-8 text-center">
|
|
17
|
+
<p>This content requires experience cookies.</p>
|
|
18
|
+
<p>Please enable them in your privacy settings.</p>
|
|
19
|
+
</div>
|
|
20
|
+
}
|
|
21
|
+
>
|
|
22
|
+
<InteractiveWidget />
|
|
23
|
+
</Frame>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Compound Components
|
|
27
|
+
|
|
28
|
+
Build fully custom placeholder layouts:
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
<Frame.Root category="marketing">
|
|
32
|
+
<Frame.Title category="marketing" />
|
|
33
|
+
<Frame.Button category="marketing" />
|
|
34
|
+
</Frame.Root>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
* `Frame.Root` - Container with default placeholder styling
|
|
38
|
+
* `Frame.Title` - Displays a consent-request message with the category name
|
|
39
|
+
* `Frame.Button` - Button that opens the consent dialog for the specified category
|
|
40
|
+
|
|
41
|
+
## Automatic Category Registration
|
|
42
|
+
|
|
43
|
+
When `Frame` mounts, it automatically adds its `category` to the active `consentCategories` list. This means you don't need to explicitly list the category in your provider's `consentCategories` option - if a `Frame` component uses it, it will be registered.
|
|
44
|
+
|
|
45
|
+
## Props
|
|
46
|
+
|
|
47
|
+
|Property|Value|
|
|
48
|
+
|:--|:--|
|
|
49
|
+
|Type Name|\`FrameProps\`|
|
|
50
|
+
|Source Path|\`./packages/react/src/components/frame/types.ts\`|
|
|
51
|
+
|
|
52
|
+
\*ExtractedTypeTable: Could not extract "FrameProps" from "./packages/react/src/components/frame/types.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|