Accessibility
Accessibility is built in, not bolted on. Every BIMA component ships with semantic markup, ARIA state management, full keyboard support, and a visible focus ring — so you meet WCAG 2.1 AA by default.
Accessible by default
One of BIMA's guiding principles is accessible by default — every component meets WCAG 2.1 AA, and keyboard and screen-reader support are not optional. You get the right roles, states, focus behaviour, and contrast without writing any extra code; you just use the components as documented.
Accessibility depends on using the markup as shown in each component's docs. The ARIA attributes and keyboard handlers are wired to specific class names and data-bima-* hooks — keep them intact and the behaviour comes for free.
What's built in
The framework covers the core pillars of an accessible component library:
| Feature | How BIMA handles it |
|---|---|
| Semantic HTML | Components are built on the right native elements — <button>, <nav>, <dialog>-style modals, lists — so assistive tech gets correct semantics out of the box. |
| ARIA roles & states | Interactive components manage aria-expanded (dropdown, accordion, collapse), aria-selected (tabs), aria-modal (modal, offcanvas), and aria-current="page" (active nav item) automatically. |
| Keyboard navigation | Everything interactive is reachable and operable by keyboard. Tabs support Arrow / Home / End keys; menus and dialogs respond to Enter, Space, and Escape. |
| Focus trap & restore | Modal and offcanvas trap focus inside the open panel and restore focus to the trigger element when closed, so keyboard users never get lost behind an overlay. |
| Escape to close | Dropdowns, modals, and offcanvas panels all close on the Esc key. |
| Visible focus ring | A 2px :focus-visible outline (in the focus token colour, with offset) appears for keyboard users without cluttering mouse interaction. |
| Reduced motion | A prefers-reduced-motion media query collapses transitions and animations for users who opt out of motion — both in CSS and in the JS behaviours. |
| AA colour contrast | The status tokens pair each tinted background with an AA-compliant text colour (≥4.5:1) — success, warning, error, info, and neutral all clear the bar. |
| Screen-reader-only text | .bima-visually-hidden / .bima-sr-only hide content visually while keeping it in the accessibility tree for screen readers. |
ARIA roles & states
You don't toggle these attributes yourself — the JS keeps them in sync with the visual state. As a dropdown or accordion opens, its trigger flips aria-expanded; the active tab carries aria-selected="true"; an open modal or offcanvas exposes aria-modal="true" and manages aria-hidden on the rest; and the current navigation item is marked aria-current="page".
<nav class="bima-nav" aria-label="Primary"> <a class="bima-nav__link" href="/" aria-current="page">Dashboard</a> <a class="bima-nav__link" href="/reports">Reports</a> <a class="bima-nav__link" href="/settings">Settings</a> </nav>
Keyboard & focus
All interactive components are fully keyboard operable. Beyond standard Tab traversal, the dialog-style components manage focus carefully:
- Focus trap — while a modal or offcanvas is open, Tab cycles only within the panel.
- Focus restore — closing the panel returns focus to the element that opened it.
- Escape closes — Esc dismisses dropdowns, modals, and offcanvas.
- Roving keys — tab lists respond to ← → Home End.
The focus ring is driven by :focus-visible, so it shows for keyboard navigation but stays out of the way for pointer clicks. Don't remove outlines globally — let the token-coloured ring do its job.
Reduced motion
BIMA respects the user's motion preference. When prefers-reduced-motion: reduce is set, transitions and animations are reduced to near-instant and smooth scrolling is disabled — communicated state changes still happen, just without the movement.
/* Shipped in variables.css */
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
scroll-behavior: auto !important;
}
}Visually hidden text
Sometimes a control is clear visually (an icon-only button) but gives a screen reader nothing to announce. Add a label with .bima-visually-hidden (or its alias .bima-sr-only): the text is removed from the visual layout but remains in the accessibility tree.
The button shows only an × glyph, but a screen reader announces “Close dialog”.
<button class="bima-btn bima-btn--secondary"> <span aria-hidden="true">×</span> <span class="bima-visually-hidden">Close dialog</span> </button>
Pair a .bima-visually-hidden label with aria-hidden="true" on the decorative glyph, so the icon isn't announced twice or read as a stray character.
Colour contrast
The semantic status tokens are designed in pairs: a tinted *-bg surface and an AA-compliant *-text colour. Always pair background:*-bg with color:*-text — never a *-bg with the solid * fill. The measured ratios on their tints:
| Status | Text token | Contrast on its -bg |
|---|---|---|
| Success | --bima-success-text | 5.3:1 |
| Warning | --bima-warning-text | 4.8:1 |
| Error | --bima-error-text | 5.9:1 |
| Info | --bima-info-text | 5.6:1 |
| Neutral | --bima-neutral-text | 6.4:1 |