Accessibility with Lever UI
Your app supplies names, instructions, validation messages, focus flow, and contrast. Parts and props: Button, Field, Input.
Name controls and describe errors
Wrap an Input in Field to link its label, helper text, error text, and
state. Give each field an id that is unique on the page. Field.ErrorText
shows when invalid is true.
import { createSignal, type JSX } from 'solid-js';
import { Button, Field, Input } from '@leverui/components';
/** Keep validation state reactive so the field and message change together. */
function EmailField(): JSX.Element {
const [invalid, setInvalid] = createSignal(false);
/** Reveal the error after the user requests validation. */
function validate(): void {
setInvalid(true);
}
return (
<>
<Field.Root id="email" required invalid={invalid()}>
<Field.Label>Email</Field.Label>
<Input type="email" defaultValue="draft" />
<Field.HelperText>Use an address we can reach.</Field.HelperText>
<Field.ErrorText>Enter a valid email address.</Field.ErrorText>
</Field.Root>
<Button type="button" onClick={validate}>
Check email
</Button>
</>
);
}
- Replace
validatewith your own validation. Clear the error when the value becomes valid. - Test
label[for], the inputid, andaria-describedby, not only the visible message. - An
Inputwith no visible label needs a name, such asaria-label. - Disabled, read-only, optional, and multi-control layouts: Field guide.
Keep native semantics
- Use
Buttonfor an action. It renders a native button withtype="button". Settype="submit"to submit a form.loadinganddisabledblock activation. Button does not setaria-busy; set it on the region being updated. - Give an
IconButtonanaria-labelfor its action.CloseButtondefaults to a Close label. Replace it when the context needs a more specific name. - Use a link with
hreffor navigation. A Button withas="a"keeps link semantics. - Keep the names and descriptions of compound controls. Put
Dialog.TitleandDialog.Descriptioninside an open dialog. Keep its trigger and close control keyboard reachable.
Focus, keyboard, and portals
- Composition can change keyboard and focus behavior. Test tab order, Enter and Space, Escape where supported, and focus return after an overlay closes.
- Overlay in a portal: keep the trigger, title, and content in the same component context.
asChild: apply the supplied props to the native element in its render function.- Do not replace a native control with a styled
div. - If
asorasChildchanges the element, recheck role, name, keyboard, ref, and disabled behavior.
Check appearance and interaction together
- After overriding
--leverui-*colors, check text and control contrast, focus indicators, disabled states, and light and dark scopes. See the theme guide. - Respect reduced-motion preferences in motion you add.
- Smoke check: find controls by role and name, inspect label and description links, use the keyboard, and run an automated scan. A scan alone does not prove focus order or clear validation.
- Hydration checks: server rendering.