@c15t/nextjs 2.0.0-rc.4 → 2.0.0-rc.6
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/dist/headless.cjs +1 -1
- package/dist/iab/styles.css +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/libs/browser-initial-data.cjs +1 -0
- package/dist/libs/browser-initial-data.js +1 -0
- package/dist/libs/initial-data.cjs +1 -1
- package/dist/libs/initial-data.js +1 -1
- package/dist/styles.css +1 -0
- package/dist/types.cjs +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.js +1 -1
- package/dist-types/headless.d.ts +1 -0
- package/{dist → dist-types}/index.d.ts +4 -3
- package/dist-types/libs/browser-initial-data.d.ts +9 -0
- package/{dist → dist-types}/libs/initial-data.d.ts +1 -2
- package/dist-types/types.d.ts +38 -0
- package/dist-types/version.d.ts +1 -0
- package/docs/README.md +73 -0
- package/docs/building-headless-components.md +250 -0
- package/docs/callbacks.md +117 -0
- package/docs/components/consent-banner.md +174 -0
- package/docs/components/consent-dialog-link.md +59 -0
- package/docs/components/consent-dialog-trigger.md +103 -0
- package/docs/components/consent-dialog.md +137 -0
- package/docs/components/consent-manager-provider.md +423 -0
- package/docs/components/consent-widget.md +78 -0
- package/docs/components/dev-tools.md +63 -0
- package/docs/components/frame.md +73 -0
- package/docs/concepts/client-modes.md +163 -0
- package/docs/concepts/consent-categories.md +97 -0
- package/docs/concepts/consent-models.md +116 -0
- package/docs/concepts/cookie-management.md +122 -0
- package/docs/concepts/glossary.md +23 -0
- package/docs/concepts/initialization-flow.md +141 -0
- package/docs/concepts/policy-packs.md +229 -0
- package/docs/headless.md +184 -0
- package/docs/hooks/use-color-scheme.md +40 -0
- package/docs/hooks/use-consent-manager/checking-consent.md +94 -0
- package/docs/hooks/use-consent-manager/location-info.md +95 -0
- package/docs/hooks/use-consent-manager/overview.md +390 -0
- package/docs/hooks/use-consent-manager/setting-consent.md +92 -0
- package/docs/hooks/use-draggable.md +57 -0
- package/docs/hooks/use-focus-trap.md +41 -0
- package/docs/hooks/use-reduced-motion.md +35 -0
- package/docs/hooks/use-ssr-status.md +31 -0
- package/docs/hooks/use-text-direction.md +49 -0
- package/docs/hooks/use-translations.md +117 -0
- package/docs/iab/consent-banner.md +95 -0
- package/docs/iab/consent-dialog.md +135 -0
- package/docs/iab/overview.md +119 -0
- package/docs/iab/use-gvl-data.md +208 -0
- package/docs/iframe-blocking.md +107 -0
- package/docs/integrations/databuddy.md +186 -0
- package/docs/integrations/google-tag-manager.md +153 -0
- package/docs/integrations/google-tag.md +149 -0
- package/docs/integrations/linkedin-insights.md +109 -0
- package/docs/integrations/meta-pixel.md +342 -0
- package/docs/integrations/microsoft-uet.md +112 -0
- package/docs/integrations/overview.md +89 -0
- package/docs/integrations/posthog.md +177 -0
- package/docs/integrations/tiktok-pixel.md +113 -0
- package/docs/integrations/x-pixel.md +143 -0
- package/docs/internationalization.md +197 -0
- package/docs/network-blocker.md +178 -0
- package/docs/optimization.md +156 -0
- package/docs/policy-packs.md +246 -0
- package/docs/quickstart.md +155 -0
- package/docs/script-loader.md +300 -0
- package/docs/server-side.md +171 -0
- package/docs/styling/classnames.md +84 -0
- package/docs/styling/color-scheme.md +82 -0
- package/docs/styling/css-variables.md +92 -0
- package/docs/styling/overview.md +312 -0
- package/docs/styling/slots.md +93 -0
- package/docs/styling/tailwind.md +115 -0
- package/docs/styling/tokens.md +214 -0
- package/docs/troubleshooting.md +146 -0
- package/package.json +20 -13
- package/dist/headless.d.ts +0 -2
- package/dist/headless.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/libs/initial-data.d.ts.map +0 -1
- package/dist/types.d.ts +0 -16
- package/dist/types.d.ts.map +0 -1
- package/dist/version.d.ts +0 -2
- package/dist/version.d.ts.map +0 -1
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Styling Overview
|
|
3
|
+
description: Five approaches for theming consent components — design tokens, component slots, CSS variables, className, and noStyle mode.
|
|
4
|
+
---
|
|
5
|
+
c15t's theming system gives you multiple levels of control, from high-level design tokens to complete style removal.
|
|
6
|
+
|
|
7
|
+
The flow:
|
|
8
|
+
|
|
9
|
+
1. **Define** tokens (colors, spacing, radius, etc.) in JavaScript
|
|
10
|
+
2. Tokens are **injected** as CSS custom properties (`--c15t-*`) at runtime
|
|
11
|
+
3. Components **consume** these variables in their default styles
|
|
12
|
+
4. You **override** at any level: tokens, slots, CSS variables, or raw classNames
|
|
13
|
+
|
|
14
|
+
## Styling Approaches
|
|
15
|
+
|
|
16
|
+
|Approach|Control|Use When|
|
|
17
|
+
|--|--|--|
|
|
18
|
+
|**Tokens**|High|Changing global colors, typography, spacing, radius, shadows, or motion|
|
|
19
|
+
|**Slots**|Medium|Targeting specific component parts (e.g., the banner title, dialog footer)|
|
|
20
|
+
|**CSS Variables**|Medium|Overriding `--c15t-*` variables from external CSS|
|
|
21
|
+
|**className**|Medium|Passing class names to components or slots|
|
|
22
|
+
|**noStyle**|Full|Removing all default styles, building from scratch|
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { type Theme, ConsentManagerProvider, ConsentBanner, ConsentDialog } from '@c15t/nextjs';
|
|
28
|
+
|
|
29
|
+
const theme = {
|
|
30
|
+
colors: {
|
|
31
|
+
primary: '#6366f1',
|
|
32
|
+
primaryHover: '#4f46e5',
|
|
33
|
+
},
|
|
34
|
+
radius: {
|
|
35
|
+
md: '0.75rem',
|
|
36
|
+
lg: '1rem',
|
|
37
|
+
},
|
|
38
|
+
slots: {
|
|
39
|
+
consentBannerTitle: 'text-xl font-semibold',
|
|
40
|
+
buttonPrimary: 'rounded-full',
|
|
41
|
+
},
|
|
42
|
+
} satisfies Theme;
|
|
43
|
+
|
|
44
|
+
export function ConsentManager({ children }) {
|
|
45
|
+
return (
|
|
46
|
+
<ConsentManagerProvider
|
|
47
|
+
options={{
|
|
48
|
+
mode: 'hosted',
|
|
49
|
+
backendURL: '/api/c15t',
|
|
50
|
+
theme,
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
53
|
+
<ConsentBanner />
|
|
54
|
+
<ConsentDialog />
|
|
55
|
+
{children}
|
|
56
|
+
</ConsentManagerProvider>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Styling Paths
|
|
62
|
+
|
|
63
|
+
### 1. Design tokens
|
|
64
|
+
|
|
65
|
+
Set global values for colors, typography, spacing, radius, shadows, and motion:
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
options={{ theme: { colors: { primary: '#6366f1' } } }}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 2. Component slots
|
|
72
|
+
|
|
73
|
+
Target specific component parts via the `slots` object:
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
options={{ theme: { slots: { consentBannerTitle: 'text-2xl font-bold' } } }}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 3. CSS variables
|
|
80
|
+
|
|
81
|
+
Override `--c15t-*` custom properties in your stylesheet.
|
|
82
|
+
|
|
83
|
+
### 4. className prop
|
|
84
|
+
|
|
85
|
+
Pass className directly to components:
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
<ConsentBanner className="my-custom-banner" />
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### 5. noStyle prop
|
|
92
|
+
|
|
93
|
+
Strip all default styles and build from scratch (best paired with [Headless Mode](../headless)):
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
<ConsentBanner noStyle />
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Common Styling Tasks
|
|
100
|
+
|
|
101
|
+
### Change brand color globally
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
options={{ theme: { colors: { primary: '#0ea5e9', primaryHover: '#0284c7' } } }}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Make the banner card more compact
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
options={{ theme: { spacing: { md: '0.75rem', lg: '1rem' } } }}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Round primary/secondary buttons
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
options={{ theme: { slots: { buttonPrimary: 'rounded-full', buttonSecondary: 'rounded-full' } } }}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Change consent action button styles semantically
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
options={{
|
|
123
|
+
theme: {
|
|
124
|
+
consentActions: {
|
|
125
|
+
default: { mode: 'stroke' },
|
|
126
|
+
accept: { variant: 'primary', mode: 'stroke' },
|
|
127
|
+
customize: { variant: 'neutral', mode: 'ghost' },
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
}}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Use `theme.consentActions` when you want to change the stock banner/dialog button treatment without rewriting the component layout. Policy packs still control action arrangement and primary-action hints. The theme controls whether those actions render as `stroke`, `filled`, `ghost`, or `lighter`.
|
|
134
|
+
|
|
135
|
+
### Enable dark mode safely
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
options={{
|
|
139
|
+
colorScheme: 'system',
|
|
140
|
+
theme: {
|
|
141
|
+
colors: { surface: '#ffffff', text: '#1f2937' },
|
|
142
|
+
dark: { surface: '#111827', text: '#f9fafb' },
|
|
143
|
+
},
|
|
144
|
+
}}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
> ⚠️ **Warning:**
|
|
148
|
+
> noStyle: true removes layout and visual defaults. Use it only when you want full control.Use either tokens/slots or raw CSS variable overrides intentionally to avoid conflicting style sources.For dark mode, c15t supports .dark and .c15t-dark.
|
|
149
|
+
|
|
150
|
+
## API Reference
|
|
151
|
+
|
|
152
|
+
### Theme
|
|
153
|
+
|
|
154
|
+
|Property|Type|Description|Default|Required|
|
|
155
|
+
|:--|:--|:--|:--|:--:|
|
|
156
|
+
|colors|ColorTokens \|undefined|Color palette for light mode.|-|Optional|
|
|
157
|
+
|dark|ColorTokens \|undefined|Dark mode color overrides.|-|Optional|
|
|
158
|
+
|typography|TypographyTokens \|undefined|Typography settings for text elements.|-|Optional|
|
|
159
|
+
|spacing|SpacingTokens \|undefined|Spacing scale for internal padding and margins.|-|Optional|
|
|
160
|
+
|radius|RadiusTokens \|undefined|Border radius scale for rounded corners.|-|Optional|
|
|
161
|
+
|shadows|ShadowTokens \|undefined|Box shadow scale for depth and elevation.|-|Optional|
|
|
162
|
+
|motion|MotionTokens \|undefined|Animation and transition timing.|-|Optional|
|
|
163
|
+
|consentActions|Object \|undefined|Semantic button styling for consent actions.|-|Optional|
|
|
164
|
+
|slots|ComponentSlots \|undefined|Component-specific style overrides.|-|Optional|
|
|
165
|
+
|
|
166
|
+
#### `colors` ColorTokens
|
|
167
|
+
|
|
168
|
+
Color palette for light mode.
|
|
169
|
+
|
|
170
|
+
|Property|Type|Description|Default|Required|
|
|
171
|
+
|:--|:--|:--|:--|:--:|
|
|
172
|
+
|primary|string \|undefined|Primary brand/accent color for interactive elements.|-|Optional|
|
|
173
|
+
|primaryHover|string \|undefined|Hover/active state for primary elements.|-|Optional|
|
|
174
|
+
|surface|string \|undefined|Main background color for panels and containers.|-|Optional|
|
|
175
|
+
|surfaceHover|string \|undefined|Hover state for surface elements.|-|Optional|
|
|
176
|
+
|border|string \|undefined|Border color for containers and inputs.|-|Optional|
|
|
177
|
+
|borderHover|string \|undefined|Hover state for bordered elements.|-|Optional|
|
|
178
|
+
|text|string \|undefined|Primary text color for headings and body.|-|Optional|
|
|
179
|
+
|textMuted|string \|undefined|Muted text color for secondary content.|-|Optional|
|
|
180
|
+
|textOnPrimary|string \|undefined|Text color for content on primary background.|-|Optional|
|
|
181
|
+
|overlay|string \|undefined|Overlay color for modal backdrops.|-|Optional|
|
|
182
|
+
|switchTrack|string \|undefined|Toggle track color (off state).|-|Optional|
|
|
183
|
+
|switchTrackActive|string \|undefined|Toggle track color (on state).|-|Optional|
|
|
184
|
+
|switchThumb|string \|undefined|Toggle thumb color.|-|Optional|
|
|
185
|
+
|
|
186
|
+
#### `dark` ColorTokens
|
|
187
|
+
|
|
188
|
+
Dark mode color overrides.
|
|
189
|
+
|
|
190
|
+
|Property|Type|Description|Default|Required|
|
|
191
|
+
|:--|:--|:--|:--|:--:|
|
|
192
|
+
|primary|string \|undefined|Primary brand/accent color for interactive elements.|-|Optional|
|
|
193
|
+
|primaryHover|string \|undefined|Hover/active state for primary elements.|-|Optional|
|
|
194
|
+
|surface|string \|undefined|Main background color for panels and containers.|-|Optional|
|
|
195
|
+
|surfaceHover|string \|undefined|Hover state for surface elements.|-|Optional|
|
|
196
|
+
|border|string \|undefined|Border color for containers and inputs.|-|Optional|
|
|
197
|
+
|borderHover|string \|undefined|Hover state for bordered elements.|-|Optional|
|
|
198
|
+
|text|string \|undefined|Primary text color for headings and body.|-|Optional|
|
|
199
|
+
|textMuted|string \|undefined|Muted text color for secondary content.|-|Optional|
|
|
200
|
+
|textOnPrimary|string \|undefined|Text color for content on primary background.|-|Optional|
|
|
201
|
+
|overlay|string \|undefined|Overlay color for modal backdrops.|-|Optional|
|
|
202
|
+
|switchTrack|string \|undefined|Toggle track color (off state).|-|Optional|
|
|
203
|
+
|switchTrackActive|string \|undefined|Toggle track color (on state).|-|Optional|
|
|
204
|
+
|switchThumb|string \|undefined|Toggle thumb color.|-|Optional|
|
|
205
|
+
|
|
206
|
+
#### `typography` TypographyTokens
|
|
207
|
+
|
|
208
|
+
Typography settings for text elements.
|
|
209
|
+
|
|
210
|
+
|Property|Type|Description|Default|Required|
|
|
211
|
+
|:--|:--|:--|:--|:--:|
|
|
212
|
+
|fontFamily|string \|undefined|Font family for all components.|-|Optional|
|
|
213
|
+
|fontSize|Object \|undefined|Font sizes for text hierarchy.|-|Optional|
|
|
214
|
+
|fontWeight|Object \|undefined|Font weights for emphasis.|-|Optional|
|
|
215
|
+
|lineHeight|Object \|undefined|Line heights for readability.|-|Optional|
|
|
216
|
+
|
|
217
|
+
#### `spacing` SpacingTokens
|
|
218
|
+
|
|
219
|
+
Spacing scale for internal padding and margins.
|
|
220
|
+
|
|
221
|
+
|Property|Type|Description|Default|Required|
|
|
222
|
+
|:--|:--|:--|:--|:--:|
|
|
223
|
+
|xs|string \|undefined|@default '0.25rem' (4px)|-|Optional|
|
|
224
|
+
|sm|string \|undefined|@default '0.5rem' (8px)|-|Optional|
|
|
225
|
+
|md|string \|undefined|@default '1rem' (16px)|-|Optional|
|
|
226
|
+
|lg|string \|undefined|@default '1.5rem' (24px)|-|Optional|
|
|
227
|
+
|xl|string \|undefined|@default '2rem' (32px)|-|Optional|
|
|
228
|
+
|
|
229
|
+
#### `radius` RadiusTokens
|
|
230
|
+
|
|
231
|
+
Border radius scale for rounded corners.
|
|
232
|
+
|
|
233
|
+
|Property|Type|Description|Default|Required|
|
|
234
|
+
|:--|:--|:--|:--|:--:|
|
|
235
|
+
|sm|string \|undefined|@default '0.25rem' (4px)|-|Optional|
|
|
236
|
+
|md|string \|undefined|@default '0.5rem' (8px)|-|Optional|
|
|
237
|
+
|lg|string \|undefined|@default '0.75rem' (12px)|-|Optional|
|
|
238
|
+
|full|string \|undefined|@default '9999px'|-|Optional|
|
|
239
|
+
|
|
240
|
+
#### `shadows` ShadowTokens
|
|
241
|
+
|
|
242
|
+
Box shadow scale for depth and elevation.
|
|
243
|
+
|
|
244
|
+
|Property|Type|Description|Default|Required|
|
|
245
|
+
|:--|:--|:--|:--|:--:|
|
|
246
|
+
|sm|string \|undefined|@default '0 1px 2px hsla(0, 0%, 0%, 0.05)'|-|Optional|
|
|
247
|
+
|md|string \|undefined|@default '0 4px 12px hsla(0, 0%, 0%, 0.08)'|-|Optional|
|
|
248
|
+
|lg|string \|undefined|@default '0 8px 24px hsla(0, 0%, 0%, 0.12)'|-|Optional|
|
|
249
|
+
|
|
250
|
+
#### `motion` MotionTokens
|
|
251
|
+
|
|
252
|
+
Animation and transition timing.
|
|
253
|
+
|
|
254
|
+
|Property|Type|Description|Default|Required|
|
|
255
|
+
|:--|:--|:--|:--|:--:|
|
|
256
|
+
|duration|Object \|undefined|Duration presets for transitions.|-|Optional|
|
|
257
|
+
|easing|string \|undefined|Default CSS easing function for general animation curves.|-|Optional|
|
|
258
|
+
|easingOut|string \|undefined|CSS easing function for enter/exit animations. Use for modals, tooltips, dropdowns, and any element entering or exiting.|-|Optional|
|
|
259
|
+
|easingInOut|string \|undefined|CSS easing function for on-screen movement. Use when elements already on screen need to move or morph.|-|Optional|
|
|
260
|
+
|easingSpring|string \|undefined|CSS easing function with spring-like overshoot. Use for playful, bouncy animations.|-|Optional|
|
|
261
|
+
|
|
262
|
+
#### `consentActions`
|
|
263
|
+
|
|
264
|
+
Semantic button styling for consent actions.
|
|
265
|
+
|
|
266
|
+
|Property|Type|Description|Default|Required|
|
|
267
|
+
|:--|:--|:--|:--|:--:|
|
|
268
|
+
|default|ConsentActionStyle \|undefined|-|-|Optional|
|
|
269
|
+
|accept|ConsentActionStyle \|undefined|-|-|Optional|
|
|
270
|
+
|reject|ConsentActionStyle \|undefined|-|-|Optional|
|
|
271
|
+
|customize|ConsentActionStyle \|undefined|-|-|Optional|
|
|
272
|
+
|
|
273
|
+
#### `slots` ComponentSlots
|
|
274
|
+
|
|
275
|
+
Component-specific style overrides.
|
|
276
|
+
|
|
277
|
+
|Property|Type|Description|Default|Required|
|
|
278
|
+
|:--|:--|:--|:--|:--:|
|
|
279
|
+
|consentBanner|SlotStyle \|undefined|Root wrapper for the consent banner portal content.|-|Optional|
|
|
280
|
+
|consentBannerCard|SlotStyle \|undefined|Main card container for banner content and actions.|-|Optional|
|
|
281
|
+
|consentBannerHeader|SlotStyle \|undefined|Header region containing title and description.|-|Optional|
|
|
282
|
+
|consentBannerTitle|SlotStyle \|undefined|Banner title text element.|-|Optional|
|
|
283
|
+
|consentBannerDescription|SlotStyle \|undefined|Banner description text element.|-|Optional|
|
|
284
|
+
|consentBannerFooter|SlotStyle \|undefined|Footer container for banner action buttons.|-|Optional|
|
|
285
|
+
|consentBannerFooterSubGroup|SlotStyle \|undefined|Nested button group inside the banner footer.|-|Optional|
|
|
286
|
+
|consentBannerOverlay|SlotStyle \|undefined|Backdrop overlay rendered behind the banner when enabled.|-|Optional|
|
|
287
|
+
|consentDialog|SlotStyle \|undefined|Root wrapper for the consent dialog modal.|-|Optional|
|
|
288
|
+
|consentDialogCard|SlotStyle \|undefined|Main dialog card container.|-|Optional|
|
|
289
|
+
|consentDialogHeader|SlotStyle \|undefined|Dialog header region containing title and description.|-|Optional|
|
|
290
|
+
|consentDialogTitle|SlotStyle \|undefined|Dialog title text element.|-|Optional|
|
|
291
|
+
|consentDialogDescription|SlotStyle \|undefined|Dialog description text element.|-|Optional|
|
|
292
|
+
|consentDialogContent|SlotStyle \|undefined|Dialog content region (typically holds ConsentWidget).|-|Optional|
|
|
293
|
+
|consentDialogFooter|SlotStyle \|undefined|Dialog footer container with actions/branding.|-|Optional|
|
|
294
|
+
|consentDialogOverlay|SlotStyle \|undefined|Backdrop overlay rendered behind the dialog.|-|Optional|
|
|
295
|
+
|consentWidget|SlotStyle \|undefined|Root wrapper for the consent widget/preferences panel.|-|Optional|
|
|
296
|
+
|consentWidgetAccordion|SlotStyle \|undefined|Accordion region listing consent categories.|-|Optional|
|
|
297
|
+
|consentWidgetFooter|SlotStyle \|undefined|Footer area for widget actions and links.|-|Optional|
|
|
298
|
+
|consentWidgetBranding|SlotStyle \|undefined|Branding element rendered in the widget footer.|-|Optional|
|
|
299
|
+
|frame|SlotStyle \|undefined|Frame wrapper used by blocking placeholders (e.g., iframe blocking).|-|Optional|
|
|
300
|
+
|iabConsentBanner|SlotStyle \|undefined|Root wrapper for the IAB consent banner.|-|Optional|
|
|
301
|
+
|iabConsentBannerCard|SlotStyle \|undefined|Main card container for IAB banner content.|-|Optional|
|
|
302
|
+
|iabConsentBannerHeader|SlotStyle \|undefined|Header region for IAB banner title/description.|-|Optional|
|
|
303
|
+
|iabConsentBannerFooter|SlotStyle \|undefined|Footer container for IAB banner actions.|-|Optional|
|
|
304
|
+
|iabConsentBannerOverlay|SlotStyle \|undefined|Backdrop overlay rendered behind the IAB banner.|-|Optional|
|
|
305
|
+
|iabConsentDialog|SlotStyle \|undefined|Root wrapper for the IAB consent dialog.|-|Optional|
|
|
306
|
+
|iabConsentDialogCard|SlotStyle \|undefined|Main card container for IAB dialog content.|-|Optional|
|
|
307
|
+
|iabConsentDialogHeader|SlotStyle \|undefined|Header region for IAB dialog title/description.|-|Optional|
|
|
308
|
+
|iabConsentDialogFooter|SlotStyle \|undefined|Footer container for IAB dialog actions.|-|Optional|
|
|
309
|
+
|iabConsentDialogOverlay|SlotStyle \|undefined|Backdrop overlay rendered behind the IAB dialog.|-|Optional|
|
|
310
|
+
|buttonPrimary|SlotStyle \|undefined|Shared primary button style used across consent components.|-|Optional|
|
|
311
|
+
|buttonSecondary|SlotStyle \|undefined|Shared secondary button style used across consent components.|-|Optional|
|
|
312
|
+
|toggle|SlotStyle \|undefined|Shared toggle/switch style used for category controls.|-|Optional|
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Component Slots
|
|
3
|
+
description: Target individual component parts with styles using the slot system - className strings or inline style objects.
|
|
4
|
+
---
|
|
5
|
+
## What are Slots?
|
|
6
|
+
|
|
7
|
+
Slots let you target specific parts of consent components with styles. Each component is built from named "slots" (e.g., `consentBannerTitle`, `consentDialogFooter`) that you can style individually.
|
|
8
|
+
|
|
9
|
+
## Using Slots
|
|
10
|
+
|
|
11
|
+
Pass slot styles in the theme's `slots` object:
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
const theme = {
|
|
15
|
+
slots: {
|
|
16
|
+
// String value = className
|
|
17
|
+
consentBannerTitle: 'text-xl font-bold text-gray-900',
|
|
18
|
+
|
|
19
|
+
// Object value = className + inline styles
|
|
20
|
+
consentBannerCard: {
|
|
21
|
+
className: 'rounded-xl shadow-lg',
|
|
22
|
+
style: { maxWidth: '600px' },
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
} satisfies Theme;
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Slot Style Types
|
|
29
|
+
|
|
30
|
+
Each slot accepts either a `string` (treated as className) or a `SlotStyle` object:
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
// String: treated as className
|
|
34
|
+
consentBannerTitle: 'my-custom-class'
|
|
35
|
+
|
|
36
|
+
// Object: className + style + noStyle
|
|
37
|
+
consentBannerTitle: {
|
|
38
|
+
className: 'my-custom-class',
|
|
39
|
+
style: { color: 'red', fontSize: '1.5rem' },
|
|
40
|
+
noStyle: false, // Set true to remove default styles for this slot
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Available Slots
|
|
45
|
+
|
|
46
|
+
Use the typed API reference below for the full slot list and descriptions. It stays in sync with the actual component slot surface.
|
|
47
|
+
|
|
48
|
+
## API Reference
|
|
49
|
+
|
|
50
|
+
### ComponentSlots
|
|
51
|
+
|
|
52
|
+
|Property|Type|Description|Default|Required|
|
|
53
|
+
|:--|:--|:--|:--|:--:|
|
|
54
|
+
|consentBanner|SlotStyle \|undefined|Root wrapper for the consent banner portal content.|-|Optional|
|
|
55
|
+
|consentBannerCard|SlotStyle \|undefined|Main card container for banner content and actions.|-|Optional|
|
|
56
|
+
|consentBannerHeader|SlotStyle \|undefined|Header region containing title and description.|-|Optional|
|
|
57
|
+
|consentBannerTitle|SlotStyle \|undefined|Banner title text element.|-|Optional|
|
|
58
|
+
|consentBannerDescription|SlotStyle \|undefined|Banner description text element.|-|Optional|
|
|
59
|
+
|consentBannerFooter|SlotStyle \|undefined|Footer container for banner action buttons.|-|Optional|
|
|
60
|
+
|consentBannerFooterSubGroup|SlotStyle \|undefined|Nested button group inside the banner footer.|-|Optional|
|
|
61
|
+
|consentBannerOverlay|SlotStyle \|undefined|Backdrop overlay rendered behind the banner when enabled.|-|Optional|
|
|
62
|
+
|consentDialog|SlotStyle \|undefined|Root wrapper for the consent dialog modal.|-|Optional|
|
|
63
|
+
|consentDialogCard|SlotStyle \|undefined|Main dialog card container.|-|Optional|
|
|
64
|
+
|consentDialogHeader|SlotStyle \|undefined|Dialog header region containing title and description.|-|Optional|
|
|
65
|
+
|consentDialogTitle|SlotStyle \|undefined|Dialog title text element.|-|Optional|
|
|
66
|
+
|consentDialogDescription|SlotStyle \|undefined|Dialog description text element.|-|Optional|
|
|
67
|
+
|consentDialogContent|SlotStyle \|undefined|Dialog content region (typically holds ConsentWidget).|-|Optional|
|
|
68
|
+
|consentDialogFooter|SlotStyle \|undefined|Dialog footer container with actions/branding.|-|Optional|
|
|
69
|
+
|consentDialogOverlay|SlotStyle \|undefined|Backdrop overlay rendered behind the dialog.|-|Optional|
|
|
70
|
+
|consentWidget|SlotStyle \|undefined|Root wrapper for the consent widget/preferences panel.|-|Optional|
|
|
71
|
+
|consentWidgetAccordion|SlotStyle \|undefined|Accordion region listing consent categories.|-|Optional|
|
|
72
|
+
|consentWidgetFooter|SlotStyle \|undefined|Footer area for widget actions and links.|-|Optional|
|
|
73
|
+
|consentWidgetBranding|SlotStyle \|undefined|Branding element rendered in the widget footer.|-|Optional|
|
|
74
|
+
|frame|SlotStyle \|undefined|Frame wrapper used by blocking placeholders (e.g., iframe blocking).|-|Optional|
|
|
75
|
+
|iabConsentBanner|SlotStyle \|undefined|Root wrapper for the IAB consent banner.|-|Optional|
|
|
76
|
+
|iabConsentBannerCard|SlotStyle \|undefined|Main card container for IAB banner content.|-|Optional|
|
|
77
|
+
|iabConsentBannerHeader|SlotStyle \|undefined|Header region for IAB banner title/description.|-|Optional|
|
|
78
|
+
|iabConsentBannerFooter|SlotStyle \|undefined|Footer container for IAB banner actions.|-|Optional|
|
|
79
|
+
|iabConsentBannerOverlay|SlotStyle \|undefined|Backdrop overlay rendered behind the IAB banner.|-|Optional|
|
|
80
|
+
|iabConsentDialog|SlotStyle \|undefined|Root wrapper for the IAB consent dialog.|-|Optional|
|
|
81
|
+
|iabConsentDialogCard|SlotStyle \|undefined|Main card container for IAB dialog content.|-|Optional|
|
|
82
|
+
|iabConsentDialogHeader|SlotStyle \|undefined|Header region for IAB dialog title/description.|-|Optional|
|
|
83
|
+
|iabConsentDialogFooter|SlotStyle \|undefined|Footer container for IAB dialog actions.|-|Optional|
|
|
84
|
+
|iabConsentDialogOverlay|SlotStyle \|undefined|Backdrop overlay rendered behind the IAB dialog.|-|Optional|
|
|
85
|
+
|buttonPrimary|SlotStyle \|undefined|Shared primary button style used across consent components.|-|Optional|
|
|
86
|
+
|buttonSecondary|SlotStyle \|undefined|Shared secondary button style used across consent components.|-|Optional|
|
|
87
|
+
|toggle|SlotStyle \|undefined|Shared toggle/switch style used for category controls.|-|Optional|
|
|
88
|
+
|
|
89
|
+
### SlotStyle
|
|
90
|
+
|
|
91
|
+
|Property|Type|Description|Default|Required|
|
|
92
|
+
|:--|:--|:--|:--|:--:|
|
|
93
|
+
|SlotStyle|SlotStyle|Type alias for SlotStyle|-|✅ Required|
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Tailwind CSS
|
|
3
|
+
description: Use Tailwind CSS utility classes to style consent components via the slot system.
|
|
4
|
+
---
|
|
5
|
+
c15t works with Tailwind CSS out of the box. Use the `slots` theme option to apply Tailwind utility classes to any component part.
|
|
6
|
+
|
|
7
|
+
## Setup
|
|
8
|
+
|
|
9
|
+
Import the standard c15t stylesheet once at the root of your app:
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
// React
|
|
13
|
+
import '@c15t/react/styles.css';
|
|
14
|
+
|
|
15
|
+
// Next.js
|
|
16
|
+
import '@c15t/nextjs/styles.css';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Tailwind v4
|
|
20
|
+
|
|
21
|
+
Tailwind v4 automatically scans your source files. Declare c15t's layer order once in your global CSS so utilities stay last:
|
|
22
|
+
|
|
23
|
+
```css
|
|
24
|
+
@layer theme, base, components, c15t, utilities;
|
|
25
|
+
@import "tailwindcss";
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Tailwind v3
|
|
29
|
+
|
|
30
|
+
Keep Tailwind's directives in your app stylesheet, but wrap `@tailwind base` in a native `base` layer so c15t's `@layer c15t` rules can sit above Preflight:
|
|
31
|
+
|
|
32
|
+
```css title="app/globals.css"
|
|
33
|
+
@layer base, components, c15t;
|
|
34
|
+
|
|
35
|
+
@layer base {
|
|
36
|
+
@tailwind base;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@tailwind components;
|
|
40
|
+
@tailwind utilities;
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Then add c15t's component paths to your `content` array:
|
|
44
|
+
|
|
45
|
+
```js title="tailwind.config.js"
|
|
46
|
+
module.exports = {
|
|
47
|
+
content: [
|
|
48
|
+
'./src/**/*.{js,ts,jsx,tsx}',
|
|
49
|
+
'./node_modules/@c15t/react/**/*.{js,mjs}',
|
|
50
|
+
'./node_modules/@c15t/nextjs/**/*.{js,mjs}',
|
|
51
|
+
],
|
|
52
|
+
};
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Using Tailwind with Slots
|
|
56
|
+
|
|
57
|
+
Apply Tailwind classes via the theme's `slots` object:
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { type ReactNode } from 'react';
|
|
61
|
+
import { type Theme, ConsentManagerProvider } from '@c15t/nextjs';
|
|
62
|
+
|
|
63
|
+
const theme = {
|
|
64
|
+
slots: {
|
|
65
|
+
consentBanner: 'fixed bottom-0 inset-x-0 z-50',
|
|
66
|
+
consentBannerCard: 'mx-auto max-w-2xl rounded-t-2xl bg-white p-6 shadow-2xl',
|
|
67
|
+
consentBannerTitle: 'text-lg font-semibold text-gray-900',
|
|
68
|
+
consentBannerDescription: 'mt-2 text-sm text-gray-600',
|
|
69
|
+
consentBannerFooter: 'mt-4 flex flex-wrap gap-3',
|
|
70
|
+
buttonPrimary: 'rounded-full bg-indigo-600 px-6 py-2.5 text-sm font-medium text-white hover:bg-indigo-700',
|
|
71
|
+
buttonSecondary: 'rounded-full border border-gray-300 px-6 py-2.5 text-sm font-medium text-gray-700 hover:bg-gray-50',
|
|
72
|
+
toggle: 'data-[state=checked]:bg-indigo-600',
|
|
73
|
+
},
|
|
74
|
+
} satisfies Theme;
|
|
75
|
+
|
|
76
|
+
export function ConsentManager({ children }: { children: ReactNode }) {
|
|
77
|
+
return (
|
|
78
|
+
<ConsentManagerProvider options={{ theme, mode: 'hosted', backendURL: '/api/c15t' }}>
|
|
79
|
+
{children}
|
|
80
|
+
</ConsentManagerProvider>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Dark Mode with Tailwind
|
|
86
|
+
|
|
87
|
+
Combine Tailwind's dark mode with c15t's `dark` tokens:
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
const theme = {
|
|
91
|
+
colors: {
|
|
92
|
+
primary: '#6366f1',
|
|
93
|
+
surface: '#ffffff',
|
|
94
|
+
text: '#1f2937',
|
|
95
|
+
},
|
|
96
|
+
dark: {
|
|
97
|
+
primary: '#818cf8',
|
|
98
|
+
surface: '#1f2937',
|
|
99
|
+
text: '#f9fafb',
|
|
100
|
+
},
|
|
101
|
+
slots: {
|
|
102
|
+
consentBannerCard: 'bg-white dark:bg-gray-900 shadow-lg dark:shadow-gray-900/30',
|
|
103
|
+
consentBannerTitle: 'text-gray-900 dark:text-gray-100',
|
|
104
|
+
},
|
|
105
|
+
} satisfies Theme;
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Optional: noStyle Mode
|
|
109
|
+
|
|
110
|
+
If you want Tailwind to own all layout and visual styling, use `noStyle: true`.
|
|
111
|
+
|
|
112
|
+
> ℹ️ **Info:**
|
|
113
|
+
> When using noStyle: true with Tailwind, you're responsible for all layout and visual styling. Start with slots first, then switch to noStyle only when you need full control.
|
|
114
|
+
|
|
115
|
+
For full custom markup (not just styles), see [Headless Mode](../headless).
|