Skip to main content

TanStack Start Components

ConsentBanner

Render the banner

Render ConsentBanner once inside ConsentRoot, next to ConsentDialog. The quickstart does this in the root route. With an awaited root loader, the banner is part of the server HTML for visitors who owe a choice.

src/routes/__root.tsx
import { ConsentBanner } from 'c15t/tanstack-start';

// Inside ConsentRoot:
<ConsentBanner variant="bar" position="bottom" />;

The banner renders what the active policy requires. A choice prompt shows reject and accept at equal prominence, plus customize when the policy offers it. A notice prompt shows an "OK" button and a "Do not sell or share my data" button that opens preferences. A policy with prompt: 'none' renders nothing, and so does a visitor whose policy has not resolved.

Props

PropTypeDefaultDescription
titleReactNodetranslationOverrides the title. Under a notice the default is cookieBanner.noticeTitle.
descriptionReactNodetranslationOverrides the description. Under a notice the default is cookieBanner.noticeDescription.
acceptButtonTextReactNodecommon.acceptAllAccept label.
rejectButtonTextReactNodecommon.rejectAllReject label.
customizeButtonTextReactNodecommon.customizeCustomize label.
dismissButtonTextReactNodecommon.acknowledgeLabel of the notice acknowledgement.
variantPromptVariantfloatingShape of the prompt. See Variants.
positionPromptPositionper variantWhere the prompt sits. Must be valid for the variant.
blockingbooleantrue on wallBackdrop, scroll lock, focus trap, and no outside dismissal, as one value.
layoutConsentBannerLayoutpolicy defaultOrders and groups actions. Required actions the layout omits are restored.
primaryButtonConsentBannerButton | ConsentBannerButton[]'customize'Which actions get the primary treatment. On a notice, dismiss is primary when it is the only action.
direction'row' | 'column''row'How action groups flow.
legalLinks(keyof LegalLinks)[] | nullnoneWhich configured legal links render inline.
hideBrandingbooleanfalseHides the "Secured by" tag.
scrollLockbooleanunsetDeprecated. Use blocking to control scrolling, focus and backdrop together.
trapFocusbooleanunsetDeprecated. Use blocking.
disableAnimationbooleanfalseSkips enter and exit animations.
noStylebooleanfalseRemoves the built-in styling from every part.

Variants

The policy decides which actions the banner offers. The variant decides their shape. Set variant on the banner, or options.presentation.prompt on ConsentRoot for every banner. The prop wins.

VariantPositionsDefault
floatingbottom-left, bottom-right, top-left, top-right, bottom-center, top-centerbottom-left
bartop, bottombottom
widgetbottom-left, bottom-right, top-left, top-rightbottom-right
wallcentercenter

A wall blocks the page until the visitor answers. A notice never blocks, so a notice wall falls back to floating. Every part is also available as ConsentBanner.<Part> for custom layouts, such as ConsentBanner.Root, ConsentBanner.Card and ConsentBanner.PolicyActions. Customize covers tokens and slots.