compose-focus-navigation
Skill1 starsChanged 39 days agoMITView on GitHub
Use when writing or reviewing Jetpack Compose UI for TV, keyboard, desktop, accessibility focus, D-pad navigation, FocusRequester, focusProperties, key events, or initial focus behavior.
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- chrisbanes/skillsedited, first seen Jun 18, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- chrisbanes/skills★ 1.2k93% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository34 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- android-benchmark-comparisonSkill
- build-and-verifySkill
- compose-animationsSkill
- compose-component-designSkill
- compose-performanceSkill
- compose-state-and-effectsSkill
- compose-ui-testing-patternsSkill
- deliver-specSkill
- diagnosing-bugsSkill
- domain-modelingSkill
- gradle-runSkill
- grillingSkill
- grounded-writingSkill
- implement-with-subagentsSkill
- kotlin-api-designSkill
- kotlin-architectureSkill
- kotlin-concurrency-and-flowSkill
- kotlin-control-flowSkill
- kotlin-skill-routerSkill
- new-featureSkill
- prototypeSkill
- release-kotlin-librarySkill
- researchSkill
- review-prSkill
- run-github-projectSkill
- run-on-deviceSkill
- setup-environmentSkill
- setup-issue-trackerSkill
- shepherdSkill
- tddSkill
- to-planSkill
- triageSkill
- wayfinderSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 5 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Start with components that already participate in focus.
- Very specific: line 27
Keep default spatial search unless a concrete edge, jump, or trap is wrong.
- Distinctive: line 30
Test with one concrete key/D-pad interaction and focused semantics.
- Distinctive: line 48
Call focus requests from an effect, not the composable body:
- Distinctive: line 58
If the target appears after loading, key the request to the condition:
- Very specific: line 68
Use focusProperties only when default spatial search is wrong:
- Distinctive: line 91
Test focus through user input:
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Compose: focus navigation
Core principle
Focus is stateful UI behavior: make targets and exceptional edges explicit, then drive and verify it through the user's keyboard, D-pad, or remote input.
Procedure
- Start with components that already participate in focus. Add a hook only for a requested behavior:
| Need | Add |
| Normal button/text field/clickable focus | Nothing extra; use the focusable component |
| Programmatic initial/restored focus | FocusRequester + Modifier.focusRequester(...) |
| Visual or state reaction to focus changes | Modifier.onFocusChanged { ... } |
| Custom interactive surface that is not already focusable | Modifier.focusable() plus role/semantics as appropriate |
- Request initial or restored focus from
LaunchedEffect, keyed to the condition that makes the target present. For lazy content, keep requesters by stable item id and request only after the item is composed. InsideAnimatedContent, use the content lambda's target consistently for rendered identity, tags, requester ownership, and the effect key; captured outer state gives outgoing and incoming content the same identity. In a review, a finding aboutrequestFocus()running in the composable body is incomplete until it names the event or keyed effect that should issue the request after its target is available. - Keep default spatial search unless a concrete edge, jump, or trap is wrong. Encode only those exceptions with
focusProperties. - Handle keys only for behavior that is not normal click or traversal. Consume exactly the handled event; throttle rapid D-pad work at its expensive owner, not across the screen.
- Restore by semantic identity after refresh: retain the focused id when it exists, otherwise choose a deterministic fallback.
- Test with one concrete key/D-pad interaction and focused semantics. When the behavior under review is user-triggered, do not substitute direct state mutation or leave the input conditional. Use screenshots only for the focus appearance.
- Finish when all intentional targets and exceptional edges are encoded, loading/refresh behavior has a stable focus policy, and tests use the same input model as users.
For example, request and observe focus only when both behaviors are required:
val requester = remember { FocusRequester() }
Button(
onClick = onClick,
modifier = Modifier
.focusRequester(requester)
.onFocusChanged { state -> isFocused = state.isFocused },
) {
Text("Play")
}Call focus requests from an effect, not the composable body:
val initialFocus = remember { FocusRequester() }
LaunchedEffect(initialFocus) {
initialFocus.requestFocus()
}If the target appears after loading, key the request to the condition:
LaunchedEffect(items.isNotEmpty()) {
if (items.isNotEmpty()) {
firstItemRequester.requestFocus()
}
}Use focusProperties only when default spatial search is wrong:
Modifier.focusProperties {
up = headerRequester
down = firstRowRequester
left = FocusRequester.Cancel
}Too many hard-coded links create stale focus graphs. For special key behavior, consume only the handled event:
Modifier.onPreviewKeyEvent { event ->
if (event.type == KeyEventType.KeyUp && event.key == Key.Back) {
onBack()
true
} else {
false
}
}Test focus through user input:
composeTestRule.onNodeWithTag("screen").performKeyInput {
pressKey(Key.DirectionDown)
}
composeTestRule.onNodeWithTag("play-button").assertIsFocused()Broader test-shape choices are in Compose UI testing patterns.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

