Skip to main content

Accessibility

Prism's accessibility subpath exports vision simulation tools: VisionModeProvider, useVisionMode, getVisionModeStyles and VISION_MODE_OPTIONS. It does not export a general ARIA utility library. Component accessibility also depends on the labels, semantics and focus behaviour supplied by the application.

Simulate colour perception​

import {
VisionModeProvider, useVisionMode, VISION_MODE_OPTIONS,
type VisionMode,
} from '@omnitron-dev/prism/accessibility';

function VisionSelector() {
const { mode, setMode } = useVisionMode();
return (
<label>
Vision simulation
<select value={mode} onChange={(event) => setMode(event.target.value as VisionMode)}>
{VISION_MODE_OPTIONS.map((option) => (
<option key={option.value} value={option.value}>{option.label}</option>
))}
</select>
</label>
);
}

export function Preview() {
return (
<VisionModeProvider defaultMode="normal" disablePersistence>
<VisionSelector />
<p>Review your application controls in each mode.</p>
</VisionModeProvider>
);
}

The modes are normal, protanopia, deuteranopia, tritanopia and achromatopsia. The hook also exposes toggle, reset and isFiltered. The provider installs SVG filters and applies the selected mode globally. Use it in a development or preview surface with a visible reset control.

Provider optionMeaning
defaultModeInitial mode when no persisted preference takes precedence
storageKeyPersistence key; defaults to prism-vision-mode
disablePersistenceStarts without reading or writing the stored preference
attributeNameAttribute used for the filter; defaults to data-vision

Simulation helps find colour-dependent distinctions. It does not measure contrast, establish conformance or replace keyboard and assistive-technology testing.

Compose accessible screens​

SurfaceApplication responsibility
Icon-only actionsSupply a clear accessible name such as aria-label
InputsAssociate labels and descriptions; connect validation errors to the field
Dialogs and drawersVerify initial focus, Escape behaviour and focus restoration
TablesPreserve headings; expose sort state and label row actions
Async resultsProvide loading, empty and failure states; announce meaningful changes
Status coloursInclude text or an icon shape in addition to colour
MotionRespect reduced-motion preferences

Start with the semantics of the underlying control. Avoid replacing a button with a clickable div. Custom renderers and slots can remove semantics that a default component supplies, so test the final composition.

Verification loop​

Navigate a representative screen using only Tab, Shift+Tab, Enter, Space and Escape. Check visible focus in both themes, then test zoom and a narrow viewport. Run the repository's pnpm -F @omnitron-dev/prism test:a11y suite for its test application and add checks for your own screens. Read React testing for component-level examples.