Get License
Free
Pro

Cookie Banner

Fixed consent banner. Hidden until the client confirms localStorage has no stored choice (SSR-safe). Accept and Reject persist that choice and emit. Use a unique storageKey per site.

freenew

Demo

This preview uses a dedicated storage key so it does not collide with a production banner. Reset to show it again.

Last choice: none

HTML

Installation

Run the following command to add this component to your project:

bash

npx base-ui-cli add cookie-banner

API Reference

For AI agents

Copy a prompt with the registry name, CLI install, and import — or add the Base UI MCP server.

bash

npx -y base-ui-mcp

Base UI provides standalone components. Import the exact elements you want to use into your component.

typescript (Example)

// Install: npx base-ui-cli add cookie-banner
// Paths are relative to aliases.components (default: src/app/components)
import { CookieBannerComponent } from './cookie-banner/cookie-banner.component';

@Component({
  selector: 'app-your-component',
  imports: [
    CookieBannerComponent
  ],
  template: `...`
})
export class YourComponent {}

API for cookie-banner — generated from JSDoc in the library source.

API reference for cookie-banner
APIMemberTypeDefaultDescription
base-cookie-bannerclassstring''Extra host classes merged via `cn()`.
base-cookie-bannerstorageKeyunknown'base-cookie-consent'`localStorage` key used to remember the choice.
base-cookie-bannertitleunknown'We use cookies'Heading shown beside the cookie icon.
base-cookie-bannermessageunknown'We use cookies to remember your theme and keep the docs working. You can reject non-essential cookies.'Supporting copy under the title.
base-cookie-banneracceptLabelunknown'Accept'Label for the accept button.
base-cookie-bannerrejectLabelunknown'Reject'Label for the reject button.
base-cookie-bannerpolicyHrefstring''Optional privacy policy URL. Hidden when empty.
base-cookie-bannerpolicyLabelunknown'Privacy policy'Label for the privacy policy link.
base-cookie-banner(accepted)voidEmitted after the user accepts (and the choice is stored).
base-cookie-banner(rejected)voidEmitted after the user rejects (and the choice is stored).
base-cookie-banner(consentChange)CookieConsentEmitted with the stored consent value after accept, reject, or a successful reset.