Menu

1 / 6

Part 2: From Five Stars to One Sentence: Semantics for Custom Compose Controls

DEV Community: android·Android Expert·15 days ago
#GJysNmQL
#devtoandroid#devto#dev#rating#modifier
Reading 0:00
15s threshold

Build for Everyone · Part 2 of 5

Previously: Part 1 (“Raising the Floor”) covered the five baseline rules every screen must pass. Those rules assume standard components. This part is about the ones you build yourself.

TL;DR Material components ship with semantics. Your custom components ship with none until you add them. The semantics tree, not the pixels, is what TalkBack reads. Making a custom control accessible comes down to four moves:

Collapse it into one node: merge descendants for things people read, and clear and replace them for things people operate.

Say what it is ( contentDescription ) separately from what it currently holds ( stateDescription ).

Pick an interaction model that matches how the control behaves.

Expose actions so nobody has to hit a 20dp star precisely.

The five-stars problem

Picture a recipe app with a “Rate this recipe” row: five stars, tap one to set your score. It looks great and works perfectly with a finger.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.