# Accessibility

> What the default in-app message and content card views do for text size, VoiceOver and TalkBack, focus, touch targets and reduced motion, and what you must do for custom and HTML content.

The default views in `HeraldUI` and `herald-ui` are built to work with the platform's assistive technology out of the box. Custom views and HTML messages are yours, and so is the content of every message. This page lists what the SDK does and what remains your job.

## What the default views do

| Area | iOS | Android |
|---|---|---|
| Text size | Fonts are system text styles, so Dynamic Type applies. Long text scrolls in modal and full-screen messages. At accessibility text sizes a slideup shows at most three lines, so it never covers most of the screen. | Sizes are in `sp`, so the system font size applies. Long text scrolls in modal and full-screen messages. |
| Screen reader labels | The close button reads "Close". Message headers are marked as headings. Decorative images are hidden. | The close button reads "Close". Message headers are marked as headings. Decorative images are hidden. |
| Dismiss without gestures | Slideups and dismissible cards offer a **Dismiss** action. The escape gesture (two-finger scrub) closes any message. | Slideups and dismissible cards offer a **Dismiss** custom action. The back button closes modal, full-screen and HTML messages. |
| Focus | Modal, full-screen and HTML messages are modal for VoiceOver: focus stays inside the message until it closes, then returns to the app. Slideups do not take focus. | Modal, full-screen and HTML messages hide the app's views from TalkBack while they are up, and restore them when the message closes. Slideups do not take focus. |
| Touch targets | Buttons, the close button, slideups and tappable cards are at least 44 pt tall. The close button is 44 x 44 pt. | Buttons, the close button, slideups and tappable cards are at least 48 dp tall. The close button is 48 x 48 dp (44 x 44 dp on HTML messages, as on iOS). |
| Reduced motion | With Reduce Motion on, messages fade instead of sliding or scaling. | With **Remove animations** on (animator duration scale 0), messages appear and disappear without animation. |
| Auto-dismiss | A slideup's `dismissAfterSeconds` is ignored while VoiceOver runs, so the message stays until the user acts. | The timeout is lengthened to the user's accessibility timeout setting, or turned off when the system asks for that. |
| Image-only cards | Read as the card title, or `extras["alt"]` when there is no title. | Same |
| Labels in your language | "Close", "Dismiss" and the feed's empty text are looked up in your app's strings files. | Override `herald_close`, `herald_dismiss` and `herald_feed_empty` in your string resources. |

## What you are responsible for

### Message content

- **Alt text.** Image-only cards need a title or an `alt` extra. Modal and full-screen images are treated as decorative, so do not put information only in the image.
- **Contrast.** Per-message `style` colors override your theme in both light and dark mode. Check that text and button colors have enough contrast against the background in both. See [Theming and dark mode](/docs/in-app-messages/theming-and-dark-mode#per-message-styles).
- **Button text** that makes sense on its own: "See the plan", not "Click here".
- **Auto-dismiss.** Slideups that dismiss themselves can disappear before some users finish reading. Leave `dismissAfterSeconds` empty for anything the user must act on.

### Custom views

When you replace a default view (see [Custom views](/docs/in-app-messages/custom-views)), the presenter still handles focus, reduced motion for its own transition, and the escape gesture or back button. Your view must handle the rest:

- Use text styles (`Font.custom(_:size:relativeTo:)` on iOS, `sp` on Android) so text scales.
- Give icon-only controls a label: `.accessibilityLabel(_:)` on iOS, `contentDescription` on Android.
- Keep touch targets at 44 pt or 48 dp.
- Offer a visible way to close that calls `actions.dismiss()`.
- Mark the header as a heading: `.accessibilityAddTraits(.isHeader)` on iOS, `Modifier.semantics { heading() }` on Android.
- Respect reduced motion in any animation inside your view: `@Environment(\.accessibilityReduceMotion)` on iOS, the animator duration scale on Android.

### HTML messages

The presenter makes the web view modal and supports the escape gesture and back button, but it cannot fix the page. Write the page to the same standard as your website:

- Set `lang` on the `html` element and use real headings, buttons and links, not clickable `div`s.
- Give images `alt` text, or `alt=""` when they are decorative.
- Use relative font sizes. On iOS, `font: -apple-system-body` follows Dynamic Type.
- Include a visible close button that calls `herald.close()`, with a text label. Both SDKs add a native close button in the top corner as well, and Android's back button also closes the message.
- Respect `prefers-reduced-motion` in CSS animations.
- Test with VoiceOver and TalkBack: the page is read by the web view's own accessibility support.

### Custom content card UIs

Apply the same rules as for custom views: scalable text, labels on icons, 44 pt or 48 dp targets, and a non-gesture way to dismiss a card if you support swipe to dismiss.

## Test checklist

1. Turn on VoiceOver or TalkBack and open each message type with `debugShowInAppMessage`. Every control should be reachable and labelled, and focus should not leave a modal message.
2. Close each blocking message with the escape gesture (iOS) or back button (Android).
3. Set the largest text size. Nothing should be cut off; long messages should scroll.
4. Turn on Reduce Motion or Remove animations and check that messages no longer slide.
5. Check every message's colors in light and dark mode.

## Related

- [Custom views](/docs/in-app-messages/custom-views)
- [Customizing the feed](/docs/content-cards/customizing-the-feed)
