Accessibility Presets
a11y) that composes with light and dark mode, and each is
also a pure factory you can call yourself.The presets
grayscale—grayscalePalette. Collapses every hue onto the perceptual gray ramp; slots stay distinguishable by luminance alone.high-contrast—highContrastPalette. Adjusts each color's lightness, keeping hue and chroma, until it reaches WCAG AAA (7:1) againstbaseLight.colorblind—colorblindPalette. Moves the red–green pair that deuteranopia and protanopia confuse onto the Okabe–Ito hues;mainis kept.
A preset remaps only the brand, function and feedback slots. The contrast anchors (baseDark,
baseLight, deepDark, deepLight) pass through, so surfaces and ramps keep deriving as before.
Light
main
primary
secondary
information
success
warning
danger
Dark
main
primary
secondary
information
success
warning
danger
Grayscale
main
primary
secondary
information
success
warning
danger
High contrast
main
primary
secondary
information
success
warning
danger
Colorblind-friendly
main
primary
secondary
information
success
warning
danger
Usage
Let the reader pick a preset through the provider. The choice persists with the mode when persist is on.
import type { ChangeEvent } from 'react';
import { Select } from '@apollion-dsi/core/form/select';
import { useApollionTheme } from '@apollion-dsi/core/themes';
import type { A11yMode } from '@apollion-dsi/core/themes/mode';
const PRESETS = ['grayscale', 'high-contrast', 'colorblind'];
const OPTIONS = [{ value: '', label: 'Standard' }, ...PRESETS.map((p) => ({ value: p, label: p }))];
function A11ySelect() {
const { a11y, setA11y } = useApollionTheme();
const onChange = (e: ChangeEvent<HTMLSelectElement>) => setA11y((e.target.value || null) as A11yMode);
return <Select aria-label="Color preset" value={a11y ?? ''} onChange={onChange} options={OPTIONS} />;
}Select a theme
main
primary
secondary
information
success
warning
danger
To build a theme from a preset directly, call the factory. It takes an optional base ColorsInput —
pass your brand to derive the preset from it:
import { createTheme } from '@apollion-dsi/core/themes';
import { highContrastPalette } from '@apollion-dsi/core/themes/colors';
const theme = createTheme({ colors: highContrastPalette(myBrand) });accessibilityPalettes maps each preset name to its factory.
Okabe–Ito reference
Slot | Hue | Hex |
|---|---|---|
danger | vermilion | #D55E00 |
success | bluish green | #009E73 |
warning | orange | #E69F00 |
primary | sky blue | #56B4E9 |
information, secondary | blue | #0072B2 |