ConsentBanner

A pre-built consent banner that appears when user consent is needed. Supports custom layout, button arrangement, and full compound component composition.

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

Customizing Content

Override the default title, description, and button labels:

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):

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.

Compound Components

Build fully custom banner layouts using sub-components:

  • 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.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

Props

Loading…