Accessibility
The banner must meet WCAG 2.1 AA. Low contrast or hidden focus rings not only harm users — they can undermine informed consent, linking accessibility failures to GDPR validity.
Why accessibility matters for consent
Section titled “Why accessibility matters for consent”GDPR Article 7 requires consent to be freely given, specific, informed, and unambiguous. A banner that screen reader users cannot operate, or that keyboard users cannot tab through, may not produce legally valid consent. Regulators (ICO, CNIL) have noted that inaccessible consent mechanisms are suspect.
Focus rings
Section titled “Focus rings”Focus indicators must use outline, not box-shadow. Using box-shadow for focus rings can be clipped by overflow: hidden on ancestor elements inside the Shadow DOM.
Correct:
.ag-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px;}Incorrect — box-shadow is clipped by overflow:
/* hypothetical example */.some-selector:focus-visible { box-shadow: 0 0 0 3px var(--accent); /* clipped by parent overflow:hidden */}The default banner styles use outline for all interactive focus states. If you override focus styles, always use outline.
Contrast requirements
Section titled “Contrast requirements”| Text type | Minimum ratio | Example |
|---|---|---|
| Body text (< 18px, not bold) | 4.5:1 | .ag-desc text vs background |
| Large text (≥ 18px or ≥ 14px bold) | 3:1 | .ag-title text vs background |
| UI components (button borders) | 3:1 | .ag-btn border vs background |
Touch targets
Section titled “Touch targets”Reduced motion
Section titled “Reduced motion”Respect users who request reduced motion. Kookiok’s default animation tokens can be overridden:
@media (prefers-reduced-motion: reduce) { :host { --animation: none; } .ag-banner { animation: none !important; transition: none !important; }}Keyboard navigation
Section titled “Keyboard navigation”The banner is fully keyboard-navigable by default:
Tabcycles through interactive elements in DOM order.Enter/Spaceactivates buttons and toggles.- The banner takes focus when it opens, on Reject all where it is shown.
- Focus is trapped inside the dialog while the banner is open (
aria-modal="true"). With “Dim the page behind the banner” switched off, or while the banner is folded, it is not (aria-modal="false"):Tabmoves on to the page. Escapenever accepts. On a first view it refuses, as Reject all does; on a banner reopened over a decision it closes it and keeps the decision. Where focus is not trapped, it decides nothing on a first view.
Do not use CSS to reorder visual display without matching DOM order — order property creates a mismatch between visual and focus sequence.
Screen reader support
Section titled “Screen reader support”The banner uses semantic ARIA:
role="dialog"witharia-modalon.ag-banner:"true", or"false"while the page under the banner can be usedaria-labelledbypointing to.ag-titlearia-describedbypointing to.ag-desc- Toggle buttons in
.ag-bar-catshavearia-pressedstate - The detail panel uses
aria-hiddento suppress it from the accessibility tree when collapsed
Do not remove display: block from collapsed sections with CSS visibility: hidden — use the existing aria-hidden mechanism.
Language direction (RTL)
Section titled “Language direction (RTL)”If your site uses right-to-left text (dir="rtl"), the banner inherits direction from the host document. Test that your token overrides (e.g., --font-family) include RTL-appropriate fonts.
Checklist
Section titled “Checklist”-
--surface-textvs--surfacecontrast ≥ 4.5:1 (verify with DevTools) -
--btn-fillvs--btn-textcontrast ≥ 4.5:1 - All buttons maintain
min-height: 44px - Focus rings use
outlinenotbox-shadow -
@media (prefers-reduced-motion)override applied - Banner tested with keyboard-only navigation
- Banner tested with VoiceOver / NVDA screen reader