@affino/aria-utils
Stability: Stable
Opinionated helpers for wiring ARIA attributes on dialog-like surfaces.
Overview
Use these helpers to keep ARIA wiring deterministic in custom dialog/surface implementations.
Installation
bash
npm install @affino/aria-utilsQuick start
ts
import { ensureDialogAria } from "@affino/aria-utils"
ensureDialogAria({
surface: dialogEl,
labelId: "settings-title",
fallbackLabel: "Settings dialog",
warn: true,
})What it does
- Ensures
role="dialog"andaria-modal="true". - Applies
aria-labelledby(oraria-labelfallback). - Discovers descriptions via
[data-dialog-description]or.dialog-descriptionand wiresaria-describedby. - Emits a warning in development when no description is found.
API
ensureDialogAria(options)surface(required) - dialog root element.labelId/fallbackLabel- foraria-labelledbyoraria-label.warn- toggles dev warnings.descriptionSelectors,descriptionIdPrefix,console- customization points.
discoverDescription(surface, options)- Finds the first description node using selectors.
Related packages
@affino/dialog-core@affino/dialog-laravel@affino/focus-utils
Used by adapters
- Laravel runtime: /adapters/laravel
- Vue runtime: /adapters/vue
License
MIT