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 sizing
  • balanced — auto-fills compact and grouped layouts with moderate emphasis
  • strict — 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, and consentBannerTitle

Primary Button

Highlight specific button(s) as the primary action:

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 context
  • ConsentBanner.Card — Main content card with optional focus trapping
  • ConsentBanner.Header — Contains title and description
  • ConsentBanner.Title — Heading, defaults to translation consentBanner.title
  • ConsentBanner.Description — Description text, supports legalLinks prop
  • ConsentBanner.PolicyActions — Renders policy-aware grouped actions inside the banner footer
  • ConsentBanner.Footer — Action buttons container
  • ConsentBanner.FooterSubGroup — Groups related buttons together
  • ConsentBanner.RejectButton — Rejects all consent
  • ConsentBanner.CustomizeButton — Opens the consent dialog
  • ConsentBanner.AcceptButton — Accepts all consent
  • ConsentBanner.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.

Props

Loading…