"use client";
import { ConsentBanner } from "@pixxl-tools/components";| Prop | Type | Default | Description |
|---|---|---|---|
policyHref | string | — | Privacy policy link. |
acceptLabel | ReactNode | — | Text overrides (defaults from the catalog). |
cookieDomain | CookieDomainOption | — | Domain of the cookie mirror. { shared: ".gtktsc.com" } uses the shared domain only on that site and its subdomains (host-only on localhost and preview hosts); a string is used as is. |
cookieName | string | false | — | Cookie mirror name; false/unset keeps the decision in localStorage only. |
declineLabel | ReactNode | — | Text overrides (defaults from the catalog). |
description | ReactNode | — | Supporting text. |
headingAs | "h2" | "h3" | "p" | h2 | Heading element of the title (default h2). |
maxAgeDays | number | 365 | Ask again after this many days (default 365); Infinity never expires. Values stored without a timestamp (0.2) do not expire. |
onChange | (decision: ConsentDecision) => void | — | Called after the visitor accepts or declines. |
open | boolean | — | Always show (previews, tests), regardless of the stored decision. |
policyHrefstring
Privacy policy link.
acceptLabelReactNode
Text overrides (defaults from the catalog).
cookieDomainCookieDomainOption
Domain of the cookie mirror. { shared: ".gtktsc.com" } uses the shared domain only on that site and its subdomains (host-only on localhost and preview hosts); a string is used as is.
cookieNamestring | false
Cookie mirror name; false/unset keeps the decision in localStorage only.
declineLabelReactNode
Text overrides (defaults from the catalog).
descriptionReactNode
Supporting text.
headingAsdefault h2"h2" | "h3" | "p"
Heading element of the title (default h2).
maxAgeDaysdefault 365number
Ask again after this many days (default 365); Infinity never expires. Values stored without a timestamp (0.2) do not expire.
onChange(decision: ConsentDecision) => void
Called after the visitor accepts or declines.
openboolean
Always show (previews, tests), regardless of the stored decision.
Other props are passed to the root element (HTMLAttributes<HTMLElement>), including className, style, id and aria-* attributes.
Last decision: none yet
"use client";
import { ConsentBanner, useConsent } from "@pixxl-tools/components";
declare global {
interface Window {
gtag?: (...args: unknown[]) => void;
}
}
// Loads gtag.js once; Consent Mode defaults run before it, the app owns analytics.
function loadGtag(id: string) {
const script = document.createElement("script");
script.async = true;
script.src = `https://www.googletagmanager.com/gtag/js?id=${id}`;
document.head.append(script);
}
export function Analytics({ id }: { id: string }) {
useConsent({
onChange: (status) => {
window.gtag?.("consent", "update", {
analytics_storage: status === "granted" ? "granted" : "denied",
});
if (status === "granted") loadGtag(id);
},
});
return <ConsentBanner policyHref="/privacy" />;
}