Overlays
ConsentBanner
Cookie consent for analytics (PDPL). Reject is as easy as accept; the server reads the choice with readConsent().
import { ConsentBanner, readConsent } from "@percentsa/ui";Examples
The banner shows at the bottom of the page until a choice is made.
Code
export function ConsentBannerExample() {
const t = useT();
const s = useStrings();
const [key, setKey] = useState(0);
return (
<Stack gap={3}>
<Text size="sm" tone="muted">
<Info aria-hidden className="me-1 inline size-4" />
{t("The banner shows at the bottom of the page until a choice is made.", "يظهر الشريط أسفل الصفحة حتى يُتخذ اختيار.")}
</Text>
<Button
variant="secondary"
onClick={() => {
document.cookie = "consent=; Path=/; Max-Age=0";
setKey(key + 1);
}}
>
{t("Show it again", "أظهره مرة أخرى")} ({s.consentTitle})
</Button>
<ConsentBanner key={key} policyHref="#privacy" onChange={(c) => toast({ title: `consent=${c}` })} />
</Stack>
);
}