Documentation
Documentation
Update styles and themes
Render theme CSS
In v2 the provider built CSS from options.theme in the browser. In v3 it
doesn't. Without a change, custom colors, fonts and radii fall back to the
defaults, and you only see a development warning.
Render ConsentTheme with the same theme object, or put the output of
generateThemeCSS(theme) in your own stylesheet. Keep options.theme for
consentActions and slots. See
customization and
tokens.
The theme-to-consent-theme codemod marks a provider theme that sets
tokens with a TODO(c15t v3) comment.
A generated theme uses :root:root, so your own --c15t-* values on plain
:root lose to it. Put them in the theme instead, or raise your selector.
Stylesheets
- Remove the c15t stylesheet import, such as
@c15t/react/styles.cssor@c15t/nextjs/styles.css. The stock components inc15t/react,c15t/nextandc15t/tanstack-startrender the rules they use as<style>elements, so no stylesheet request holds back the first paint. An import you keep still styles the components, but the rules ship twice and the stylesheet still delays the first paint. - Keep an import of the v3 stylesheet, such as
c15t/react/styles.css, only with Tailwind CSS 3 or a named cascade layer, and setstyles: falsein the provider options so the components add no second copy. See stylesheets and CSS layers. Thepackages-to-c15tcodemod removes@c15t/reactand@c15t/nextjsstylesheet imports. With Tailwind CSS 3 or a cascade layer it keeps them, pointed atc15t, with aTODO(c15t v3)comment. - With manual styles,
iab/styles.cssno longer repeats the default tokens. Import it afterstyles.css. Automatic IAB styling needs neither import. - Tailwind CSS 3 needs a PostCSS plugin for c15t's
styles.css. Add'c15t/postcss-tailwind3': {}beforetailwindcssinpostcss.config, and setstyles: false. See Tailwind CSS 3. Create React App can't run the plugin. Thepostcss-tailwind3codemod adds it to an object-formpostcss.configand warns about configs it can't edit.
CSS variables and slots
| v2 | v3 |
|---|---|
--consent-widget-* | --consent-manager-*, used by ConsentDialog and ConsentWidget |
--consent-widget-accordion-* | Removed. Set --accordion-* instead. |
--frame-* | --consent-gate-* |
--consent-banner-entry-animation, --consent-banner-exit-animation | Removed |
theme.slots.frame | consentGate, consentGateTitle and consentGateButton |
theme.slots.consentDialogFooter | consentWidgetFooter |
The css-variables-to-v3 codemod renames --consent-widget-* and
--frame-* in stylesheets and inline styles, and marks
--consent-widget-accordion-* with a comment instead of renaming it, because
--accordion-* styles every accordion. theme-to-consent-theme renames
theme.slots.consentDialogFooter and marks theme.slots.frame.
theme.slots now applies in React. v2 accepted it in types and ignored it, so
check slots you set before the upgrade.