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:
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.
Compound Components
Build fully custom banner layouts using sub-components:
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.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