# Accessibility

> How Birch UI Forms labels, describes and announces every control, manages focus and errors, and works without a pointer, plus the Form Builder's keyboard model.

Forms are built on native HTML controls with real labels, so they work with keyboards, screen readers, voice control and browser autofill without extra effort on your side. This page lists what the renderer does for you and what is left to you.

## Labels and descriptions

- Every control has a visible label. Single inputs use `<label for>`; groups of options, such as radio buttons, checkbox groups, ratings and matrices, are a `<fieldset>` with a `<legend>`.
- Help text from `description` is linked to the control with `aria-describedby`, so it is read together with the label.
- Required fields carry `aria-required="true"`. The visual asterisk is hidden from assistive technology, so it is not read twice.
- Fields without a `title` fall back to their `name` as the label. Give every field a title.
- `autocomplete` tokens such as `name`, `email` and `tel` let browsers and assistive tools fill fields for the user; email fields set it automatically.

## Controls

| Field | Implementation |
| --- | --- |
| `text`, `email`, `number`, `date`, `time`, `datetime`, `textarea`, `select` | Native inputs. Number fields set `inputmode` for the right phone keyboard. |
| `radio`, `rating` | A native radio group with the `radiogroup` role. Each rating choice is named "4 of 5", so star ratings are spoken correctly. |
| `checkbox`, `checkboxgroup` | Native checkboxes. |
| `toggle` | A checkbox with the `switch` role, so it is announced as on or off. |
| `slider` | A native range input. Its value is spoken with the unit, such as "40 %", or "Not set" before the user moves it. |
| `matrix` | A table of radio buttons. Each radio is labelled by its row and column header. |
| `file` | A native file input. Each attached file has a remove button named "Remove receipt.pdf". |
| `signature` | A drawing pad with a text alternative and a **Type instead** mode: users who cannot draw type their name, and the result is stored as a signature image. |
| `computed` | An `<output>` element that announces new results politely as they change. |
| Collapsible `panel` | A toggle button in the legend with `aria-expanded`. |
| `dynamicpanel` | Each entry is a `section` labelled by its heading; remove buttons include the entry's title. |

## Errors

- An invalid field gets `aria-invalid="true"`, and its message is linked through `aria-describedby`.
- After a failed **Next** or **Submit**, an error summary appears at the top of the form in a live region, so it is announced. Each entry links to its field.
- Focus moves to the first invalid field, switching page and expanding collapsed panels if needed.
- Messages say what to do, such as "Enter a date on or after 1 Dec 2026." Keep your own `requiredMessage`, `patternMessage` and validator messages in the same style: name the expected format, for example "Use the format HM-482913."

See [Validation](https://docs.birchui.com/forms/validation.md#how-errors-are-shown).

## Focus management

- When the page changes, focus moves to the new page's heading. With `showPageTitles: false`, it moves to the first field.
- When a condition shows or hides fields while the user types, the form re-renders without losing focus.
- After adding a repeating entry, focus moves to its first field; after removing one, to the **Add** button.
- After a successful submission with a `completedMessage`, focus moves to the message.

## Pages and progress

The progress bar is a `progressbar` with its value and a text such as "Page 2 of 4: Experience". Back and Next are real buttons, and `Enter` in a text field advances like **Next**.

## Visual design

- Light and dark themes are included, and `theme: 'auto'` follows the user's colour-scheme preference. Check the contrast of any colours you override.
- Focus is always visible.
- Animations are turned off when the user prefers reduced motion.
- Layout widths such as `half` collapse to full width when the form is narrower than 540 pixels, so zooming in and narrow screens keep one field per row.

## What is up to you

- **Write good titles and help text.** A clear label is the biggest accessibility win.
- **Avoid placeholder-only instructions.** Placeholders disappear when the user types; put formats in `description`.
- **Describe images and links in markdown blocks** with meaningful link text instead of "click here".
- **Do not hide essential information** behind conditions the user cannot discover.
- **Test with real assistive technology**, especially custom validators that call your server, whose messages users will hear.

## Form Builder keyboard model

The [Form Builder](https://docs.birchui.com/forms/builder.md) is fully operable from the keyboard:

| Area | Keys |
| --- | --- |
| Toolbox | Each field type is a button. `Enter` or `Space` inserts it after the selected element, inside the selected section, or at the end of the page. |
| Canvas | Elements form a tree. `Arrow Up` and `Arrow Down` move between elements, `Home` and `End` go to the first and last. `Alt` + `Arrow Up` / `Arrow Down` reorders the element. `Enter` or `F2` renames it in place, `Delete` or `Backspace` removes it, and `Escape` selects the page. |
| Clipboard | `Ctrl` + `C`, `Ctrl` + `X`, `Ctrl` + `V` copy, cut and paste the selected element; `Ctrl` + `D` duplicates it. |
| Page tabs | `Arrow Left` and `Arrow Right` switch pages, `Home` and `End` jump to the first and last, `Delete` removes a page. |
| Designer, JSON and Preview tabs | `Arrow Left`, `Arrow Right`, `Home` and `End`. |
| Anywhere | `Ctrl` + `Z` undo, `Ctrl` + `Shift` + `Z` or `Ctrl` + `Y` redo, `Ctrl` + `S` save. Use `Cmd` instead of `Ctrl` on macOS. |

Changes such as "Copied phone" or "Undid: Edit element" are announced in a polite live region, and every panel is reachable with `Tab`. Undo and redo shortcuts are left to the browser while you type in a text field, so they undo your typing.
