Skip to content
Components, switch product

Accessibility

The components build on native controls where one exists, and on ARIA roles and states where none does. They link labels, hints and errors to the control for you. This page covers what every element shares; each component page adds its own keyboard keys and parts.

  • Fields are named by their label. There is no made-up fallback: without a label a field has no accessible name, and accessibility checkers flag it. In development builds, the date, time, range, tags and file fields also log a warning.
  • Buttons and parts with no visible text always have a name, such as the button that opens a picker, the month buttons of a calendar, the parts of a date and the buttons of a file field. Each has a prop to change it, listed in the element’s API; an empty value keeps the default.
  • Icon-only buttons take their name from button-aria-label, since they show no text. A gui-button with neither a label nor a button-aria-label logs a warning in development builds. See Button.
  • Popups are named by their field’s label, or by a default name without one.
  • Parts that only add context, such as the start and end of a range and the toolbars, have a default name that an empty value removes.
  • Hint. The hint is the field’s description, through aria-describedby, so screen readers read it after the name.
  • Errors. While errors show, the control has aria-invalid="true" and points at them with aria-errormessage. The errors container has the alert role, so screen readers announce new errors as they appear.
  • Required. required sets aria-required. The visual marker, an asterisk after the label, is hidden from screen readers so they don’t read it twice. A file upload can’t have aria-required, so its upload button has “Required” as its description.
  • Read-only and disabled. readonly sets aria-readonly; disabled disables the native control, so it leaves the tab order.

Every element works with the keyboard alone. Fields built on a native control, such as the text input or the select, keep its keys. Composite fields, such as the date and time pickers, the lists and the tags, have keys of their own: each component page lists them under Accessibility.

Popups follow the combobox pattern: focus alone never opens a picker’s or a dropdown’s panel, so moving through a form with Tab doesn’t pop anything up. A click in the field, the button at its end or Alt+↓ opens it, and Alt+↑ or Escape closes it and returns focus to the field.

The overlays build on the browser’s own popover and <dialog>, so the browser manages their focus: a dialog keeps the focus inside until it closes, then returns it to the button that opened it. A menu moves the focus to its first item, and its arrow keys move between the items. Escape closes a popover, a menu or a dialog, and hides a tooltip.

  • Focus. The focused control shows a ring, --gui-shadow-focus, in the color of --gui-border-focus. An invalid field shows --gui-shadow-focus-error instead.
  • Contrast. When you change the colors in a theme, check the text, hint, error and button colors against their backgrounds.
  • Forced colors. The carets keep the text color in Windows High Contrast and other forced-colors modes, so they stay visible.

The names, announcements and validation messages the elements produce are in English by default. Translate them for your app with configureMessages(), and set the dir attribute for a right-to-left language. See i18n.