Accessibility in Jetpack Compose

Accessibility is crucial for creating inclusive apps that everyone can use. Compose provides a foundation for building accessible UIs that make your apps usable for everyone everywhere.

Key concepts

  • Semantics: The system of representing the meaning of UI elements for accessibility services. This includes properties like descriptions, states, and actions a user can take.

  • Traversal: The order in which accessibility services like TalkBack navigate through elements on screen. You can customize this order for better user experience.

  • Accessibility Actions: Specific actions that a user can perform on a UI element, such as click, scroll, and dismiss. Your app communicates them to accessibility services.

Get started

The foundation of Compose's accessibility model and tools is semantics. See the Semantics in Compose guide for more information.

When developing your app, keep in mind from the beginning these key steps to improve the accessibility of your Compose app:

  • Consider minimum touch target sizes: Make sure clickable and interactive elements are at least 48dp. This adheres to Material Design accessibility guidelines.
  • Add click labels: Describe the click behavior with the clickable modifier or semantics modifier if you don't have direct access to clickable.
  • Describe visual elements: Use the contentDescription parameter to textually describe icons and images. Set contentDescription to null for decorative elements.
  • Define headings: Use the semantics modifier property to mark elements as headings for easier navigation.
  • Control traversal order: Use isTraversalGroup to mark groups of elements that should be read together. Utilize traversalIndex to further customize element order within those groups.

For more, see the dedicated Key steps to improve Compose accessibility guide.

Tools

  • TalkBack: Google's screen reader for Android. Activate it to test how your app's semantics work for users relying on assistive technologies.
  • Layout Inspector: Visualize and debug your app's semantics tree.
  • Compose testing APIs: Write tests that interact with semantic elements to assert the accessibility of your Compose UIs.

Codelab

To learn more about supporting accessibility in your Compose code, take the Accessibility in Jetpack Compose codelab.

Additional resources