Copy this complete component into a page file. Edit and run it in the Playground.
Loading editor…
A cookie preference notice that disappears after a visitor chooses an option or dismisses it. The decision is saved for one year in both localStorage and a first-party SameSite=Lax cookie.
| Prop | Type | Default | Description |
|---|---|---|---|
storageKey | string | "opus-cookie-consent" | Key used for both persisted values. |
placement | CookieConsentPlacement | "bottom-right" | Bottom-right, bottom-left, bottom-centre, or inline placement. |
policyHref | string | — | Optional URL for the site’s cookie policy. No policy link is rendered unless this is supplied. |
policyLabel | string | "Cookie policy" | Label for the optional cookie-policy link. |
onAccept | () => void | — | Called after accepting. |
onReject | () => void | — | Called after rejecting optional cookies. |
onDismiss | (value) => void | — | Receives accepted, rejected, or dismissed. |
persist | boolean | true | Set false for a temporary preview. |
Call resetCookieConsent() with the same storage key, then render the component again.