@c15t/nextjs 2.2.1 → 3.0.0-alpha.0
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 +102 -142
- package/README.md +4 -4
- package/dist/api.js +1 -0
- package/dist/config.js +1 -0
- package/dist/devtools.js +2 -0
- package/dist/headers.js +1 -0
- package/dist/iab/styles.css +1 -1
- package/dist/iab/styles.tw3.css +133 -19
- package/dist/index.js +1 -1
- package/dist/middleware.js +1 -0
- package/dist/node-bridge.js +1 -0
- package/dist/pages.js +1 -0
- package/dist/proxy.js +1 -0
- package/dist/root.js +2 -0
- package/dist/server.js +1 -0
- package/dist/static.js +1 -0
- package/dist/styles.css +1 -1
- package/dist/styles.tw3.css +173 -29
- package/dist/version.js +1 -1
- package/dist-types/api.d.ts +88 -0
- package/dist-types/config.d.ts +110 -0
- package/dist-types/devtools.d.ts +1 -0
- package/dist-types/headers.d.ts +4 -0
- package/dist-types/index.d.ts +28 -10
- package/dist-types/middleware.d.ts +15 -0
- package/dist-types/node-bridge.d.ts +57 -0
- package/dist-types/pages.d.ts +88 -0
- package/dist-types/proxy.d.ts +34 -0
- package/dist-types/root.d.ts +86 -0
- package/dist-types/server.d.ts +164 -0
- package/dist-types/static.d.ts +42 -0
- package/dist-types/types.d.ts +5 -36
- package/dist-types/version.d.ts +1 -1
- package/docs/README.md +102 -142
- package/docs/assets/v3/brand-bar.png +0 -0
- package/docs/assets/v3/brand-card.png +0 -0
- package/docs/assets/v3/choice-wall.png +0 -0
- package/docs/assets/v3/mobile-card.png +0 -0
- package/docs/assets/v3/preferences.png +0 -0
- package/docs/customization/overview.md +45 -0
- package/docs/customization/recipes.md +79 -0
- package/docs/customization/slots.md +55 -0
- package/docs/customization/tokens.md +76 -0
- package/docs/customization/translations.md +49 -0
- package/docs/frameworks/next/api-reference/data-fetching.md +416 -0
- package/docs/frameworks/next/app-router.md +403 -0
- package/docs/frameworks/next/client-side.md +118 -0
- package/docs/frameworks/next/components/consent-banner.md +251 -211
- package/docs/frameworks/next/components/consent-dialog-link.md +96 -35
- package/docs/frameworks/next/components/consent-dialog-trigger.md +74 -149
- package/docs/frameworks/next/components/consent-dialog.md +189 -134
- package/docs/frameworks/next/components/consent-manager-provider.md +60 -318
- package/docs/frameworks/next/components/consent-widget.md +172 -114
- package/docs/frameworks/next/components/dev-tools.md +199 -40
- package/docs/frameworks/next/components/frame.md +137 -42
- package/docs/frameworks/next/concepts/consent-categories.md +24 -89
- package/docs/frameworks/next/concepts/policy-presets.md +142 -0
- package/docs/frameworks/next/content-security-policy.md +189 -0
- package/docs/frameworks/next/data-fetching.md +74 -0
- package/docs/frameworks/next/geography-headers.md +251 -0
- package/docs/frameworks/next/headless.md +95 -185
- package/docs/frameworks/next/hooks/use-consent-manager/overview.md +42 -163
- package/docs/frameworks/next/iab/overview.md +37 -107
- package/docs/frameworks/next/optimization.md +158 -194
- package/docs/frameworks/next/pages-router.md +296 -0
- package/docs/frameworks/next/quickstart.md +31 -132
- package/docs/frameworks/next/script-loader.md +134 -467
- package/docs/frameworks/next/server-side.md +97 -130
- package/docs/frameworks/next/static-export.md +164 -0
- package/docs/frameworks/next/styling/overview.md +166 -250
- package/docs/frameworks/next/troubleshooting.md +134 -144
- package/docs/guides/consent-state.md +60 -0
- package/docs/guides/data-fetching.md +163 -0
- package/docs/guides/deployment-modes.md +63 -0
- package/docs/guides/troubleshooting.md +68 -0
- package/docs/guides/verify-consent.md +62 -0
- package/docs/integrations/adobe-analytics.md +239 -105
- package/docs/integrations/ahrefs-analytics.md +238 -104
- package/docs/integrations/amplitude.md +219 -157
- package/docs/integrations/building-integrations.md +32 -224
- package/docs/integrations/clearbit.md +247 -86
- package/docs/integrations/cloudflare-web-analytics.md +250 -84
- package/docs/integrations/crisp.md +251 -97
- package/docs/integrations/databuddy.md +259 -153
- package/docs/integrations/fathom-analytics.md +239 -96
- package/docs/integrations/google-maps.md +328 -207
- package/docs/integrations/google-tag-manager.md +248 -96
- package/docs/integrations/google-tag.md +261 -90
- package/docs/integrations/heap.md +222 -149
- package/docs/integrations/hightouch.md +225 -131
- package/docs/integrations/hotjar.md +239 -90
- package/docs/integrations/intercom.md +239 -98
- package/docs/integrations/linkedin-insights.md +243 -113
- package/docs/integrations/logrocket.md +241 -123
- package/docs/integrations/matomo-analytics.md +256 -111
- package/docs/integrations/meta-pixel.md +197 -324
- package/docs/integrations/microsoft-clarity.md +233 -114
- package/docs/integrations/microsoft-uet.md +245 -110
- package/docs/integrations/mixpanel-analytics.md +252 -87
- package/docs/integrations/openai-pixel.md +441 -0
- package/docs/integrations/overview.md +95 -133
- package/docs/integrations/pirsch.md +249 -96
- package/docs/integrations/plausible-analytics.md +241 -100
- package/docs/integrations/posthog.md +353 -214
- package/docs/integrations/promptwatch.md +251 -81
- package/docs/integrations/reddit-pixel.md +226 -173
- package/docs/integrations/rudderstack.md +244 -187
- package/docs/integrations/rybbit-analytics.md +244 -91
- package/docs/integrations/segment.md +238 -92
- package/docs/integrations/snapchat-pixel.md +240 -110
- package/docs/integrations/tiktok-pixel.md +249 -81
- package/docs/integrations/umami-analytics.md +242 -95
- package/docs/integrations/vercel-analytics.md +242 -90
- package/docs/integrations/x-pixel.md +238 -104
- package/docs/integrations/youtube.md +354 -142
- package/docs/upgrade-v3.md +334 -0
- package/iab/styles.css +1 -1
- package/iab/styles.tw3.css +1 -1
- package/package.json +106 -65
- package/readme.json +3 -3
- package/src/iab/styles.css +1 -1
- package/src/iab/styles.tw3.css +1 -1
- package/src/styles.css +1 -1
- package/src/styles.tw3.css +1 -1
- package/styles.css +1 -1
- package/styles.tw3.css +1 -1
- package/client/components/consent-dialog-link.js +0 -3
- package/client/components/integrations.js +0 -3
- package/dist/components/integrations/index.cjs +0 -1
- package/dist/components/integrations/index.js +0 -1
- package/dist/headless.cjs +0 -1
- package/dist/index.cjs +0 -1
- package/dist/libs/browser-initial-data.cjs +0 -1
- package/dist/libs/browser-initial-data.js +0 -1
- package/dist/libs/initial-data.cjs +0 -1
- package/dist/libs/initial-data.js +0 -1
- package/dist/types.cjs +0 -1
- package/dist/version.cjs +0 -1
- package/dist-types/components/integrations/index.d.ts +0 -1
- package/dist-types/libs/browser-initial-data.d.ts +0 -9
- package/dist-types/libs/initial-data.d.ts +0 -33
- package/docs/frameworks/next/building-headless-components.md +0 -379
- package/docs/frameworks/next/callbacks.md +0 -186
- package/docs/frameworks/next/concepts/client-modes.md +0 -177
- package/docs/frameworks/next/concepts/consent-models.md +0 -117
- package/docs/frameworks/next/concepts/cookie-management.md +0 -122
- package/docs/frameworks/next/concepts/glossary.md +0 -24
- package/docs/frameworks/next/concepts/initialization-flow.md +0 -149
- package/docs/frameworks/next/concepts/policy-packs.md +0 -230
- package/docs/frameworks/next/hooks/use-color-scheme.md +0 -41
- package/docs/frameworks/next/hooks/use-consent-manager/checking-consent.md +0 -96
- package/docs/frameworks/next/hooks/use-consent-manager/location-info.md +0 -97
- package/docs/frameworks/next/hooks/use-consent-manager/setting-consent.md +0 -94
- package/docs/frameworks/next/hooks/use-draggable.md +0 -59
- package/docs/frameworks/next/hooks/use-focus-trap.md +0 -42
- package/docs/frameworks/next/hooks/use-reduced-motion.md +0 -37
- package/docs/frameworks/next/hooks/use-ssr-status.md +0 -32
- package/docs/frameworks/next/hooks/use-text-direction.md +0 -50
- package/docs/frameworks/next/hooks/use-translations.md +0 -55
- package/docs/frameworks/next/iab/consent-banner.md +0 -91
- package/docs/frameworks/next/iab/consent-dialog.md +0 -129
- package/docs/frameworks/next/iab/use-gvl-data.md +0 -21
- package/docs/frameworks/next/iframe-blocking.md +0 -106
- package/docs/frameworks/next/internationalization.md +0 -207
- package/docs/frameworks/next/network-blocker.md +0 -140
- package/docs/frameworks/next/policy-packs.md +0 -248
- package/docs/frameworks/next/styling/classnames.md +0 -94
- package/docs/frameworks/next/styling/color-scheme.md +0 -84
- package/docs/frameworks/next/styling/css-variables.md +0 -53
- package/docs/frameworks/next/styling/slots.md +0 -94
- package/docs/frameworks/next/styling/tailwind.md +0 -137
- package/docs/frameworks/next/styling/tokens.md +0 -156
- package/docs/shared/concepts/client-modes.md +0 -103
- package/docs/shared/concepts/consent-categories.md +0 -41
- package/docs/shared/concepts/consent-models.md +0 -72
- package/docs/shared/concepts/cookie-management.md +0 -88
- package/docs/shared/concepts/glossary.md +0 -24
- package/docs/shared/concepts/initialization-flow.md +0 -105
- package/docs/shared/concepts/policy-packs.md +0 -225
- package/docs/shared/react/components/consent-banner.md +0 -242
- package/docs/shared/react/components/consent-dialog-link.md +0 -45
- package/docs/shared/react/components/consent-dialog-trigger.md +0 -185
- package/docs/shared/react/components/consent-dialog.md +0 -119
- package/docs/shared/react/components/consent-manager-provider.md +0 -225
- package/docs/shared/react/components/consent-widget.md +0 -121
- package/docs/shared/react/components/dev-tools.md +0 -81
- package/docs/shared/react/components/frame.md +0 -52
- package/docs/shared/react/guides/building-headless-components.md +0 -110
- package/docs/shared/react/guides/callbacks.md +0 -89
- package/docs/shared/react/guides/headless.md +0 -31
- package/docs/shared/react/guides/iframe-blocking.md +0 -65
- package/docs/shared/react/guides/internationalization.md +0 -123
- package/docs/shared/react/guides/network-blocker.md +0 -72
- package/docs/shared/react/guides/optimization.md +0 -44
- package/docs/shared/react/guides/policy-packs.md +0 -173
- package/docs/shared/react/guides/script-loader.md +0 -311
- package/docs/shared/react/hooks/use-color-scheme.md +0 -31
- package/docs/shared/react/hooks/use-consent-manager/checking-consent.md +0 -95
- package/docs/shared/react/hooks/use-consent-manager/location-info.md +0 -96
- package/docs/shared/react/hooks/use-consent-manager/overview.md +0 -74
- package/docs/shared/react/hooks/use-consent-manager/setting-consent.md +0 -93
- package/docs/shared/react/hooks/use-draggable.md +0 -30
- package/docs/shared/react/hooks/use-focus-trap.md +0 -20
- package/docs/shared/react/hooks/use-reduced-motion.md +0 -33
- package/docs/shared/react/hooks/use-ssr-status.md +0 -16
- package/docs/shared/react/hooks/use-text-direction.md +0 -38
- package/docs/shared/react/hooks/use-translations.md +0 -15
- package/docs/shared/react/iab/consent-banner.md +0 -60
- package/docs/shared/react/iab/consent-dialog.md +0 -76
- package/docs/shared/react/iab/overview.md +0 -80
- package/docs/shared/react/iab/use-gvl-data.md +0 -21
- package/docs/shared/react/styling/classnames.md +0 -93
- package/docs/shared/react/styling/color-scheme.md +0 -35
- package/docs/shared/react/styling/css-variables.md +0 -53
- package/docs/shared/react/styling/overview.md +0 -261
- package/docs/shared/react/styling/slots.md +0 -93
- package/docs/shared/react/styling/stylesheet-entrypoint.md +0 -8
- package/docs/shared/react/styling/tailwind.md +0 -88
- package/docs/shared/react/styling/tokens.md +0 -155
- package/docs/shared/troubleshooting.md +0 -82
|
@@ -1,299 +1,215 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: Styling
|
|
3
|
-
description:
|
|
4
|
-
|
|
2
|
+
title: Styling
|
|
3
|
+
description: Import the Next.js stylesheet and theme c15t components with
|
|
4
|
+
tokens, slots, and class names through ConsentRoot options.
|
|
5
5
|
group: frameworks
|
|
6
6
|
---
|
|
7
|
-
c15t's theming system gives you multiple levels of control, but most customization should stay inside the pre-built components.
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
## Stylesheet
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
4. **CSS variables or className-level overrides** — when you need to integrate with external CSS systems
|
|
15
|
-
5. **Compound components** — when you must rearrange markup while still using c15t primitives
|
|
16
|
-
6. **`noStyle`** — when you want c15t structure but you need to own all visual styling
|
|
17
|
-
7. **Headless** — when you want fully custom markup and behavior
|
|
10
|
+
Import c15t once from the global stylesheet loaded by `app/layout.tsx` in the
|
|
11
|
+
App Router or `pages/_app.tsx` in the Pages Router. With Tailwind CSS 4, place
|
|
12
|
+
it after the Tailwind import so the component layers keep their order:
|
|
18
13
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* Escalate to compound components, `noStyle`, or headless only when the structure or behavior itself must change.
|
|
23
|
-
|
|
24
|
-
## Styling Approaches
|
|
25
|
-
|
|
26
|
-
|Approach|Control|Use When|
|
|
27
|
-
|--|--|--|
|
|
28
|
-
|**Component and provider APIs**|High|Reordering actions, changing button emphasis, configuring links, hiding branding, changing copy via `i18n`|
|
|
29
|
-
|**Tokens**|High|Changing global colors, typography, spacing, radius, shadows, or motion|
|
|
30
|
-
|**Slots**|Medium|Targeting specific component parts (for example `consentBannerFooter` or `consentDialogCard`)|
|
|
31
|
-
|**CSS variables / className**|Medium|Integrating with an existing stylesheet or utility classes after tokens and slots|
|
|
32
|
-
|**Compound components**|Structure|Rearranging existing c15t primitives without going fully custom|
|
|
33
|
-
|**noStyle**|Full visuals|Keeping c15t structure but replacing all visual defaults|
|
|
34
|
-
|**Headless**|Full|Replacing both markup and behavior|
|
|
35
|
-
|
|
36
|
-
## Quick Start
|
|
37
|
-
|
|
38
|
-
```tsx
|
|
39
|
-
import { type Theme, ConsentManagerProvider, ConsentBanner, ConsentDialog } from '@c15t/nextjs';
|
|
40
|
-
|
|
41
|
-
const theme = {
|
|
42
|
-
colors: {
|
|
43
|
-
primary: '#6366f1',
|
|
44
|
-
primaryHover: '#4f46e5',
|
|
45
|
-
},
|
|
46
|
-
radius: {
|
|
47
|
-
md: '0.75rem',
|
|
48
|
-
lg: '1rem',
|
|
49
|
-
},
|
|
50
|
-
slots: {
|
|
51
|
-
consentBannerTitle: 'text-xl font-semibold',
|
|
52
|
-
buttonPrimary: 'rounded-full',
|
|
53
|
-
},
|
|
54
|
-
} satisfies Theme;
|
|
55
|
-
|
|
56
|
-
export function ConsentManager({ children }) {
|
|
57
|
-
return (
|
|
58
|
-
<ConsentManagerProvider
|
|
59
|
-
options={{
|
|
60
|
-
mode: 'hosted',
|
|
61
|
-
backendURL: '/api/c15t',
|
|
62
|
-
theme,
|
|
63
|
-
}}
|
|
64
|
-
>
|
|
65
|
-
<ConsentBanner />
|
|
66
|
-
<ConsentDialog />
|
|
67
|
-
{children}
|
|
68
|
-
</ConsentManagerProvider>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
14
|
+
```css
|
|
15
|
+
@import 'tailwindcss';
|
|
16
|
+
@import 'c15t/next/styles.css';
|
|
71
17
|
```
|
|
72
18
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
Start here before you consider compound components or headless mode.
|
|
19
|
+
Without Tailwind, omit its import. Keep the existing global CSS import in the
|
|
20
|
+
layout or `_app.tsx`. Tailwind CSS 3 uses the separate build shown below.
|
|
76
21
|
|
|
77
|
-
|
|
22
|
+
Every rule lives in `@layer components`, so unlayered utilities from Tailwind
|
|
23
|
+
v4 and atomic classes from StyleX override it without specificity tricks.
|
|
24
|
+
Tailwind v3 treats `@layer components` as its own directive, so import the
|
|
25
|
+
Tailwind 3 build from your Tailwind entry instead, between the `components`
|
|
26
|
+
and `utilities` directives:
|
|
78
27
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
* `theme.consentActions` for stock banner and dialog button treatment
|
|
85
|
-
* `i18n` on `ConsentManagerProvider` for copy changes
|
|
86
|
-
|
|
87
|
-
```tsx
|
|
88
|
-
<ConsentBanner layout={['customize', ['reject', 'accept']]} primaryButton="accept" />
|
|
28
|
+
```css
|
|
29
|
+
@tailwind base;
|
|
30
|
+
@tailwind components;
|
|
31
|
+
@import 'c15t/next/styles.tw3.css';
|
|
32
|
+
@tailwind utilities;
|
|
89
33
|
```
|
|
90
34
|
|
|
91
|
-
|
|
35
|
+
## Tokens
|
|
92
36
|
|
|
93
|
-
|
|
37
|
+
The provider snippets below are partial configuration examples. Apply them in
|
|
38
|
+
your existing Client Component wrapper, keeping its transport, prefetch,
|
|
39
|
+
children and other options. `ConsentRoot` also accepts `theme` and
|
|
40
|
+
`components` through `options`.
|
|
94
41
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
Use tokens first when the change is semantic:
|
|
100
|
-
|
|
101
|
-
* Banner card background -> `theme.colors.surface`
|
|
102
|
-
* Banner footer background -> `theme.colors.surfaceHover`
|
|
103
|
-
* Shared copy color -> `theme.colors.text` and `theme.colors.textMuted`
|
|
104
|
-
* Primary-filled surfaces such as stock branding tags and filled actions -> `theme.colors.primary` with `theme.colors.textOnPrimary` as the matching foreground override
|
|
105
|
-
|
|
106
|
-
```tsx
|
|
107
|
-
options={{
|
|
108
|
-
theme: {
|
|
109
|
-
colors: {
|
|
110
|
-
surface: '#ffffff',
|
|
111
|
-
surfaceHover: '#f6f3ee',
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
}}
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
If you set `theme.colors.primary` but omit `theme.colors.textOnPrimary`, c15t derives a readable foreground automatically. Add `textOnPrimary` only when you need to force a specific branded foreground color.
|
|
118
|
-
|
|
119
|
-
### 3. Component slots
|
|
120
|
-
|
|
121
|
-
Target specific component parts via the `slots` object:
|
|
42
|
+
Colors, radii, shadows, typography, and motion come from `--c15t-*` custom
|
|
43
|
+
properties. Set them on the provider through `theme`, or override the
|
|
44
|
+
variables directly in your CSS.
|
|
122
45
|
|
|
123
46
|
```tsx
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
47
|
+
import { ConsentProvider, defineTheme } from 'c15t/next';
|
|
48
|
+
|
|
49
|
+
const theme = defineTheme({
|
|
50
|
+
colors: { primary: '#2f6f4e' },
|
|
51
|
+
radius: { lg: '4px' },
|
|
52
|
+
consentActions: {
|
|
53
|
+
primary: { variant: 'primary', mode: 'filled' },
|
|
54
|
+
dismiss: { variant: 'neutral', mode: 'stroke' },
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
<ConsentProvider options={{ mode, theme }} />;
|
|
133
59
|
```
|
|
134
60
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
Override `--c15t-*` custom properties in your stylesheet or attach classes through slots when your app styling is driven externally.
|
|
61
|
+
`consentActions` decides how each action role looks: `default` applies to
|
|
62
|
+
every button, `primary` to whichever actions the policy or your props mark
|
|
63
|
+
primary, and `accept`, `reject`, `customize`, and `dismiss` to one role each.
|
|
64
|
+
Per-action keys win over `primary`, which wins over `default`.
|
|
140
65
|
|
|
141
|
-
|
|
66
|
+
Banner sizing has its own variables. Override them in CSS when a variant
|
|
67
|
+
needs a different footprint:
|
|
142
68
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
}}
|
|
151
|
-
```
|
|
69
|
+
| Variable | Default | Applies to |
|
|
70
|
+
| ----------------------------------- | ------- | ---------------- |
|
|
71
|
+
| `--consent-banner-max-width` | `440px` | `floating` cards |
|
|
72
|
+
| `--consent-banner-widget-max-width` | `20rem` | `widget` chips |
|
|
73
|
+
| `--consent-banner-wall-max-width` | `30rem` | `wall` cards |
|
|
152
74
|
|
|
153
|
-
##
|
|
75
|
+
## Colors by consent model
|
|
154
76
|
|
|
155
|
-
|
|
77
|
+
The primary action can change while the brand color stays the same. Set
|
|
78
|
+
`consentActions.primary` once, then select `primaryButton` per policy as
|
|
79
|
+
shown in [ConsentBanner](../components/consent-banner.md#per-policy-buttons).
|
|
156
80
|
|
|
157
|
-
|
|
81
|
+
To give opt-in and opt-out banners different colors, scope the tokens to
|
|
82
|
+
the root's attributes. Include hover and foreground colors when overriding
|
|
83
|
+
CSS tokens directly:
|
|
158
84
|
|
|
159
|
-
|
|
85
|
+
```css
|
|
86
|
+
[data-prompt][data-model='opt-in'] {
|
|
87
|
+
--c15t-primary: #2f6f4e;
|
|
88
|
+
--c15t-primary-hover: #24563c;
|
|
89
|
+
--c15t-text-on-primary: #fff;
|
|
90
|
+
}
|
|
160
91
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
<ConsentBanner.Description />
|
|
167
|
-
</ConsentBanner.Header>
|
|
168
|
-
<ConsentBanner.Footer>
|
|
169
|
-
<ConsentBanner.CustomizeButton />
|
|
170
|
-
<ConsentBanner.FooterSubGroup>
|
|
171
|
-
<ConsentBanner.RejectButton />
|
|
172
|
-
<ConsentBanner.AcceptButton />
|
|
173
|
-
</ConsentBanner.FooterSubGroup>
|
|
174
|
-
</ConsentBanner.Footer>
|
|
175
|
-
</ConsentBanner.Card>
|
|
176
|
-
</ConsentBanner.Root>
|
|
92
|
+
[data-prompt][data-model='opt-out'] {
|
|
93
|
+
--c15t-primary: #6b3fa0;
|
|
94
|
+
--c15t-primary-hover: #55327f;
|
|
95
|
+
--c15t-text-on-primary: #fff;
|
|
96
|
+
}
|
|
177
97
|
```
|
|
178
98
|
|
|
179
|
-
|
|
99
|
+
These colors apply to the action marked primary. Button layout and color
|
|
100
|
+
changes do not change the policy or expire a saved choice.
|
|
180
101
|
|
|
181
|
-
|
|
102
|
+
## Slots
|
|
182
103
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
104
|
+
Each component part is a slot. A slot accepts any attributes the element
|
|
105
|
+
takes, so the contract is the same whether you write class strings or pass an
|
|
106
|
+
object with `className` and `style`. Set slots on the provider under
|
|
107
|
+
`components`, keyed by component and part.
|
|
186
108
|
|
|
187
|
-
|
|
109
|
+
For a full-width notice, use the supported `bar` variant. In a Client Component
|
|
110
|
+
inside the existing boundary, replace the stock banner with:
|
|
188
111
|
|
|
189
|
-
|
|
112
|
+
```tsx title="components/regional-banner.tsx"
|
|
113
|
+
'use client';
|
|
190
114
|
|
|
191
|
-
|
|
115
|
+
import { ConsentBanner, usePolicyRule } from 'c15t/next';
|
|
192
116
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
theme: {
|
|
198
|
-
colors: {
|
|
199
|
-
surfaceHover: '#f6f3ee',
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
}}
|
|
117
|
+
export function RegionalBanner() {
|
|
118
|
+
const policy = usePolicyRule();
|
|
119
|
+
return <ConsentBanner variant={policy?.prompt === 'notice' ? 'bar' : 'floating'} />;
|
|
120
|
+
}
|
|
203
121
|
```
|
|
204
122
|
|
|
205
|
-
|
|
123
|
+
To remove the notice card's radius, add these values to the existing
|
|
124
|
+
`options.components.banner` slots. The root owns `data-prompt`, so the card
|
|
125
|
+
uses Tailwind's `group` selector to read it:
|
|
206
126
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
surface: '#fffdf8',
|
|
214
|
-
},
|
|
127
|
+
```ts
|
|
128
|
+
const bannerSlots = {
|
|
129
|
+
root: { className: 'group' },
|
|
130
|
+
card: { className: 'group-data-[prompt=notice]:rounded-none' },
|
|
131
|
+
rightLink: {
|
|
132
|
+
className: 'underline-offset-4 data-[right=opt-out]:text-red-700',
|
|
215
133
|
},
|
|
216
|
-
}
|
|
217
|
-
```
|
|
134
|
+
};
|
|
218
135
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
### Tweak the banner card, footer, or title styling without changing markup
|
|
222
|
-
|
|
223
|
-
```tsx
|
|
224
|
-
options={{
|
|
225
|
-
theme: {
|
|
226
|
-
slots: {
|
|
227
|
-
consentBannerCard: 'rounded-[28px] shadow-xl',
|
|
228
|
-
consentBannerFooter: 'border-t border-black/10 px-6',
|
|
229
|
-
consentBannerTitle: 'text-xl tracking-tight',
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
}}
|
|
136
|
+
// In the existing options.components object:
|
|
137
|
+
// banner: bannerSlots
|
|
233
138
|
```
|
|
234
139
|
|
|
235
|
-
|
|
140
|
+
The root also carries `data-variant`, so you can restyle one shape without
|
|
141
|
+
touching the others. Tailwind, giving a `bar` a brand-colored top edge and
|
|
142
|
+
tighter text:
|
|
236
143
|
|
|
237
144
|
```tsx
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
145
|
+
<ConsentProvider
|
|
146
|
+
options={{
|
|
147
|
+
mode,
|
|
148
|
+
presentation: { prompt: { variant: 'bar' } },
|
|
149
|
+
components: {
|
|
150
|
+
banner: {
|
|
151
|
+
root: { className: 'group' },
|
|
152
|
+
card: {
|
|
153
|
+
className:
|
|
154
|
+
'group-data-[variant=bar]:border-t-4 group-data-[variant=bar]:border-t-emerald-600',
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
description: {
|
|
158
|
+
banner: { className: 'group-data-[variant=bar]:text-xs' },
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
}}
|
|
162
|
+
/>
|
|
247
163
|
```
|
|
248
164
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
### Change banner copy without replacing the component
|
|
252
|
-
|
|
253
|
-
```tsx
|
|
254
|
-
options={{
|
|
255
|
-
i18n: {
|
|
256
|
-
locale: 'en',
|
|
257
|
-
messages: {
|
|
258
|
-
en: {
|
|
259
|
-
cookieBanner: {
|
|
260
|
-
title: 'We value your privacy',
|
|
261
|
-
description: 'We use cookies to improve the site and measure performance.',
|
|
262
|
-
},
|
|
263
|
-
common: {
|
|
264
|
-
acceptAll: 'Accept all',
|
|
265
|
-
rejectAll: 'Reject all',
|
|
266
|
-
customize: 'Manage preferences',
|
|
267
|
-
},
|
|
268
|
-
},
|
|
269
|
-
},
|
|
270
|
-
},
|
|
271
|
-
}}
|
|
272
|
-
```
|
|
165
|
+
`data-variant` sits on the root, so child slots use Tailwind's `group`
|
|
166
|
+
prefix to read it.
|
|
273
167
|
|
|
274
|
-
|
|
168
|
+
StyleX, spreading the result of `stylex.props()` into a slot:
|
|
275
169
|
|
|
276
170
|
```tsx
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
171
|
+
import * as stylex from '@stylexjs/stylex';
|
|
172
|
+
|
|
173
|
+
const styles = stylex.create({
|
|
174
|
+
card: { borderRadius: 0, boxShadow: 'none' },
|
|
175
|
+
rightLink: { textUnderlineOffset: 4, color: 'rgb(185 28 28)' },
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
<ConsentProvider
|
|
179
|
+
options={{
|
|
180
|
+
mode,
|
|
181
|
+
components: {
|
|
182
|
+
banner: {
|
|
183
|
+
card: stylex.props(styles.card),
|
|
184
|
+
rightLink: stylex.props(styles.rightLink),
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
}}
|
|
188
|
+
/>;
|
|
284
189
|
```
|
|
285
190
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
|
295
|
-
|
|
296
|
-
|
|
|
297
|
-
|
|
|
298
|
-
|
|
299
|
-
|
|
191
|
+
Set `noStyle` on a component to drop the built-in classes from every part and
|
|
192
|
+
keep only what your slots pass. Set `noStyle` in the provider options to do it
|
|
193
|
+
for every component.
|
|
194
|
+
|
|
195
|
+
Banner slot keys under `components.banner`:
|
|
196
|
+
|
|
197
|
+
| Key | Element |
|
|
198
|
+
| ------------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
199
|
+
| `root` | Fixed-position wrapper carrying `data-prompt`, `data-model`, `data-variant`, `data-position`, and `data-blocking` |
|
|
200
|
+
| `cardShell` | Sizes the card and holds the branding tag |
|
|
201
|
+
| `card` | The visible card, carrying `data-state` |
|
|
202
|
+
| `header` | Title and description container |
|
|
203
|
+
| `title` | Heading |
|
|
204
|
+
| `footer` | Action area |
|
|
205
|
+
| `actions` | Group of action groups |
|
|
206
|
+
| `actionGroup` | One group of equally prominent actions |
|
|
207
|
+
| `rights` | Group of right links, rendered before the actions |
|
|
208
|
+
| `rightLink` | One right link, carrying `data-action="right"` and `data-right` |
|
|
209
|
+
| `overlay` | Backdrop shown when the banner blocks the page |
|
|
210
|
+
|
|
211
|
+
Action buttons carry `data-action` and `data-variant`, and right links carry
|
|
212
|
+
`data-action="right"`, so a single rule such as `[data-action='dismiss']` or
|
|
213
|
+
`[data-action='right']` styles one role across every surface. Right links are
|
|
214
|
+
underlined text by default, so the only button on a notice is the primary
|
|
215
|
+
action.
|