Design System
Overlays

Cookie banner

Consent notice shown on first visit. Stateless by design — wire the handlers to your consent store and unmount it once a choice is made.

Purpose

The banner holds no state of its own. It renders the notice and calls back; deciding what a choice means, and remembering it, belongs to your consent store.

In real use it floats pinned to the bottom of the viewport — floating is disabled in the preview below so it sits inline.

We use cookies

We use essential cookies to make this site work, and optional analytics cookies to understand how it is used. Read our cookie policy.

Structure

PropertyValue
Surface--card, --radius-xl (12px), 1px --border, --shadow-16
WidthMax 672px
Padding20px
Icon36px --accent chip with the cookie glyph
Title14px / Inter 600
Body14px --muted-foreground
Placementfloating pins it 16px above the bottom edge, centred on wider screens

Best practices

Do

  • Give reject the same visual weight as accept.
  • Link the privacy policy from the banner itself.
  • Unmount once a choice is stored — never re-ask on every page.

Don't

  • Block the whole page behind it unless the jurisdiction requires it.
  • Set non-essential cookies before a choice has been made.
  • Steal focus to the banner on load — it announces politely by design.

Accessibility & keyboard

The banner is itself an accessibility construct — a landmark plus a live region — so screen readers both announce it on arrival and let people return to it later.

  • role="region" with aria-label="Cookie consent" makes it a named landmark, reachable from a screen reader's landmark list.
  • aria-live="polite" announces the notice when it appears, without stealing focus from the page.
  • Focus is deliberately not trapped: the page stays fully usable behind it.
  • All actions are real Buttons and the policy link a real anchor, so everything is reachable with Tab.
  • Keyboard: Tab moves through Customise (when present), Reject non-essential and Accept all in order; Enter or Space activates.

Props

PropTypeDefaultDescription
titlestring | undefined"We use cookies"Heading shown at the top of the banner.
descriptionReact.ReactNode—Short explanation of what the cookies are for.
onAcceptAll(() => void) | undefined—Called when the user accepts all cookies.
onRejectNonEssential(() => void) | undefined—Called when the user rejects non-essential cookies.
onCustomize(() => void) | undefined—Optional handler for a "Customise" action; the button is hidden when omitted.
policyHrefstring | undefined—Optional href to the cookie/privacy policy; the link is hidden when omitted.
floatingboolean | undefinedtruePin the banner to the bottom of the viewport. Disable to render it in normal flow (e.g. inside documentation previews).

On this page