ConsentBanner
ConsentBanner is a ready-to-use consent banner that appears automatically in opt-in jurisdictions (like GDPR) where explicit consent is required before tracking. In opt-out jurisdictions (like CCPA), the banner won't appear — users get an opt-out mechanism instead. It includes reject, accept, and customize buttons with configurable layout.
Basic Usage
Button Layout
The layout prop controls button arrangement. Each item is either a button ID or an array of button IDs (which groups them together):
To stack groups vertically, pair the same grouped layout with direction="column":
Policy-Driven UI Profile
When using backend runtime policies, policy.ui.uiProfile can control banner action presentation:
compact— default desktop sizingbalanced— auto-fills compact and grouped layouts with moderate emphasisstrict— always fills action controls for explicit, high-clarity layouts
Theme-Level Button Styling
Use the provider theme prop to control how stock consent actions look:
Policy packs control grouping, ordering, and direction. The theme controls button appearance.
Styling First
Info
For pure theming, stay inside the pre-built banner. Start with layout props, theme.consentActions, design tokens, and theme.slots before reaching for compound components. See Styling Overview.
The stock banner maps common visual changes to the theme system:
- Card background ->
theme.colors.surface - Footer background ->
theme.colors.surfaceHover - Card, footer, and title tweaks ->
theme.slots.consentBannerCard,consentBannerFooter, andconsentBannerTitle
Primary Button
Highlight specific button(s) as the primary action:
Legal Links
Control which legal links appear in the banner description:
Info
Legal link URLs are configured in the ConsentManagerProvider options via the legalLinks prop, not on the banner itself.
Customizing Copy
Prefer provider i18n when you want to rename the stock banner content:
Direct text props such as title, description, and acceptButtonText are still supported for one-off overrides, but i18n is the preferred path for copy changes.
Advanced: Compound Components
Use compound components only when the stock banner structure is no longer enough and you need to rearrange existing c15t primitives while keeping policy-driven action grouping and emphasis:
ConsentBanner.Root— Outermost container, provides theme contextConsentBanner.Card— Main content card with optional focus trappingConsentBanner.Header— Contains title and descriptionConsentBanner.Title— Heading, defaults to translationconsentBanner.titleConsentBanner.Description— Description text, supportslegalLinkspropConsentBanner.PolicyActions— Renders policy-aware grouped actions inside the banner footerConsentBanner.Footer— Action buttons containerConsentBanner.FooterSubGroup— Groups related buttons togetherConsentBanner.RejectButton— Rejects all consentConsentBanner.CustomizeButton— Opens the consent dialogConsentBanner.AcceptButton— Accepts all consentConsentBanner.Overlay— Optional backdrop overlay
For a fixed layout that intentionally ignores policy grouping, render the footer manually:
Using renderAction with c15t Defaults
ConsentBanner.PolicyActions renders stock c15t buttons and translations by default.
renderAction is optional. When you want custom mapping but still want the built-in c15t button behavior and copy, return the stock button compounds:
renderAction is still meant for stock button compounds. If you want completely custom button elements and click handling, use useHeadlessConsentUI() and render banner.actionGroups manually instead of ConsentBanner.PolicyActions.
If you only need styling changes, stay with tokens and slots instead of rebuilding the banner layout.