Demo
Dropdown accessibility
Documented in Accessibility and performance.
Dropdown accessibility
A Select, a Combobox with chips and a Listbox with selected, active and disabled options for keyboard, screen reader, forced-colors, touch and server-rendering checks.
Palette
RedBlue
Accent colors
Red
Orange
Yellow
Green
Blue
Violet
Demo.tsx
'use client';
import { useState } from 'react';
import { Combobox, type ComboboxValue } from '@salmonui/dropdowns/combobox';
import { Listbox, type ListboxKey } from '@salmonui/dropdowns/listbox';
import { Select, type SelectValue } from '@salmonui/dropdowns/select';
const COLORS = [
{ value: 'red', label: 'Red' },
{ value: 'orange', label: 'Orange' },
{ value: 'yellow', label: 'Yellow', disabled: true },
{ value: 'green', label: 'Green' },
{ value: 'blue', label: 'Blue' },
{ value: 'violet', label: 'Violet' },
];
// One of each dropdown with selected, active and disabled options, for keyboard,
// screen reader, forced-colors and touch checks.
export default function DropdownAccessibilityDemo() {
const [color, setColor] = useState<SelectValue | null>('green');
const [colors, setColors] = useState<readonly ComboboxValue[]>(['red', 'blue']);
const [listed, setListed] = useState<readonly ListboxKey[]>(['orange']);
return (
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 24, alignItems: 'start' }}>
<div style={{ display: 'grid', gap: 4, minInlineSize: 200 }}>
<label htmlFor="dd-a11y-select">Favourite color</label>
<Select id="dd-a11y-select" data={COLORS} value={color} onValueChange={setColor} clearable />
</div>
<div style={{ display: 'grid', gap: 4, minInlineSize: 240 }}>
<span id="dd-a11y-combobox">Palette</span>
<Combobox aria-labelledby="dd-a11y-combobox" multiple data={COLORS} value={colors} onValueChange={(next) => setColors(next)} />
</div>
<div style={{ display: 'grid', gap: 4, minInlineSize: 200 }}>
<span id="dd-a11y-listbox">Accent colors</span>
<Listbox aria-labelledby="dd-a11y-listbox" multiple indicator="checkbox" data={COLORS} value={listed} onValueChange={(next) => setListed(next)} />
</div>
</div>
);
}
- Focus: Tab to each control and open it. Focus stays on the trigger or
input while the active option moves (
aria-activedescendant), returns to it after you pick with the pointer, and the focused control shows the theme focus ring. - High contrast: turn on Windows high contrast, or emulate
forced-colors: activein the browser's rendering tools. Selected options useHighlight, the active option an outline, the disabled "Yellow"GrayText, and chips and fields keep their borders. - Contrast: every color comes from the theme variables derived from the five seeds; switch the site's color scheme to compare light and dark.
- Touch: options, triggers and chip remove buttons are at least 24 × 24 px, and nothing appears on hover only.
- Server rendering: view the page source. It holds the triggers, the value labels, the chips and the Listbox options, never a popup.
- The site tests run axe-core over this demo closed and open with zero
violations (
docs/site/tests/dropdowns.spec.ts).