← All Components
<mth-cookie-banner>
Accessible cookie consent notice supporting one-click accept all, reject optional, and granular category preferences.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
Ready · interact with <mth-cookie-banner>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/cookie-banner"></script>
<mth-cookie-banner position="bottom">Example</mth-cookie-banner>import '@methane-ui/ui/cookie-banner';
import '@methane-ui/react';
export function Example() {
return <mth-cookie-banner position="bottom">Example</mth-cookie-banner>;
}<script setup lang="ts">
import '@methane-ui/ui/cookie-banner';
</script>
<template>
<mth-cookie-banner position="bottom">Example</mth-cookie-banner>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/cookie-banner';
import { MthCookieBannerDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthCookieBannerDirective],
template: `<mth-cookie-banner position="bottom">Example</mth-cookie-banner>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/cookie-banner';
import MthCookieBanner from '@methane-ui/svelte/MthCookieBanner.svelte';
</script>
<MthCookieBanner position="bottom">Example</MthCookieBanner>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
open | open | boolean | false | Controls whether the cookie banner is visible. |
position | position | 'bottom' | 'top' | 'floating' | "bottom" | Placement mode (bottom, top, or floating). |
heading | heading | string | "" | Optional heading text overriding default localized title. |
analytics | analytics | boolean | false | Whether optional analytics cookies are enabled. |
marketing | marketing | boolean | false | Whether optional marketing cookies are enabled. |
showPreferences | show-preferences | boolean | false | Expands the granular consent checkboxes. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-open | undefined | Cancelable event fired before opening the banner. |
mth-after-open | undefined | Fired after opening the banner. |
mth-close | { reason: string } | Cancelable event fired before closing the banner. |
mth-after-close | undefined | Fired after closing the banner. |
mth-consent | { essential: boolean; analytics: boolean; marketing: boolean } | Fired when consent preferences are confirmed. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| Escape | both | open | Dismisses the banner without accepting optional cookies. |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | Focus ownership matches focusModel="none". | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 1 APG keyboard transitions across LTR/RTL. | mth-cookie-banner.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(open), :state(preferences-open). | Conformance suite |
| i18n | Routes 10 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |