# Accessibility (a11y)

> Generous touch targets, contrast, text that scales, and multisensory feedback in CrossFly.

Source: https://crossfly.dev/docs/best-practices/acessibilidade — CrossFly documentation. Full docs as one file: https://crossfly.dev/llms-full.txt

# Accessibility (a11y)

With honesty about what the framework offers today: focus on what is **actionable** in native/OpenGL
CrossFly. Much of a11y here **reinforces responsiveness** — font-relative sizing is respect for the
user's size setting.

## Generous touch targets
Size tappable areas with `Relative`, never tiny pixels:
```java
botao.getStyle().autoHeight(Relative.ofFont(2.5f));            // tall enough for the finger
icone.getStyle().autoWidth(Relative.ofScreen(0.12f, ScreenSize.MIN))
     .autoHeight(Relative.ofScreen(0.12f, ScreenSize.MIN));   // square that adapts
```
Rule of thumb: targets of ~48 dp equivalents — `Relative.ofFont(2.5f)` usually does the job.

## Text contrast
Ensure adequate contrast; the framework helps:
```java
int fundo  = cs.surface.color();
int texto  = ColorUtils.contrastText(fundo);                  // black/white depending on the background
int melhor = ColorUtils.getContrastColor(fundo, 0xFF000000, 0xFFFFFFFF);  // picks between 2 options
```
Respect the light/dark theme (via `Styles.setColorScheme`/`setDarkMode`) — don't hardcode colors that
ignore the mode (see [Light/dark mode](/docs/ui/theming/dark-mode)).

## Text that scales
Because fonts are measured in relative units, **text and layout scale** with the app's font zoom — a
direct consequence of using `Relative.ofFont(...)` and avoiding fixed pixels. Let the `Label` wrap;
**do not truncate** essential information.

## Multisensory feedback and voice
```java
Device.vibrate(50);            // tactile confirmation of an important action
Device.beep();                 // audible alert
Device.textToVoice(mensagem);  // voice reading (assistive)
```
Use it as **support**, not as the only channel — combine visual + tactile/audio.

## Best practices
- Touch targets with `Relative.ofFont`/`ofScreen(MIN)`; no few-pixel buttons.
- Contrast via `contrastText`/`getContrastColor`; honor light/dark.
- Don't truncate essential text; let it scale/wrap.

## Common mistakes
- Tiny buttons/icons in fixed pixels (hard to tap; don't scale).
- Fixed colors that break contrast in dark mode.
- Relying on color alone to convey state (add an icon/text).

## Limitations
**Screen reader** features depend on the platform/launcher — there is no universal semantic a11y layer
in the core. Prioritize the actionable items above.

## See also
- [Responsiveness](/docs/best-practices/responsividade) · [Light/dark mode](/docs/ui/theming/dark-mode) · Colors (Ch. 11)
