noriginmedia/norigin-spatial-navigation/norigin-spatial-navigation-react
Claude Code and agent skill by noriginmedia/norigin-spatial-navigation
- community
Checking that the SKILL.md file is still in the repository.
Use when building or modifying UIs that need directional focus (arrow keys, TV remotes, gamepads) with the Norigin Spatial Navigation library. Covers `useFocusable`, `FocusContext`, programmatic focus, and common Smart TV / set-top-box patterns.
Install
npx vskill@latest install noriginmedia/norigin-spatial-navigation/norigin-spatial-navigation-reactSKILL.md
Norigin Spatial Navigation
Library for arrow-key / remote-control focus management in React apps (Smart TVs, set-top boxes, browsers). It calculates the next focusable element based on spatial position, so you don't wire up directional logic manually.
Full documentation: https://github.com/NoriginMedia/Norigin-Spatial-Navigation/tree/main/docs
When you need details beyond this skill, read the relevant page directly:
- Concepts & hierarchy:
docs/guides/concepts.md,docs/guides/focus-hierarchy.md - Quick start & install:
docs/guides/quick-start.md,docs/guides/installation.md useFocusableAPI:docs/api-reference/useFocusable.mdSpatialNavigationAPI (init, setFocus, pause, etc.):docs/api-reference/SpatialNavigation.md- Boundaries / modals:
docs/guides/focus-boundaries.md - Programmatic focus:
docs/guides/programmatic-focus.md - Distance calculation tuning:
docs/guides/distance-calculation.md - Key mapping (custom remotes):
docs/guides/key-mapping.md - Event callbacks:
docs/guides/event-callbacks.md - Performance:
docs/guides/performance.md - Debugging:
docs/guides/debugging.md - Recipes (lists, grids, virtualization):
docs/guides/recipes.md - Accessibility labels:
docs/guides/accessibility-labels.md - RTL:
docs/guides/rtl-support.md
Mental model
Two component shapes exist:
- Leaf — interactive element that actually receives focus. Reads
focusedfromuseFocusable. - Container — wraps focusable children. Reads
focusKeyand provides it viaFocusContext.Providerso the children participate in the hierarchy. Optionally readshasFocusedChild(requirestrackChildren: true).
Every focusable component must attach the returned ref to a real DOM element. Containers must wrap children in <FocusContext.Provider value={focusKey}> — otherwise children are orphaned at the root and navigation across them breaks.
Initialization
Call init once at app startup (e.g. in App.tsx):
If you ship custom remote keys, also configure key mapping (see docs/guides/key-mapping.md).
Patterns
Leaf (button, menu item)
Container
Modal / popup (trap focus + grab on mount)
For partial trapping (e.g. block only horizontal), use focusBoundaryDirections. See docs/guides/focus-boundaries.md.
Programmatic focus from anywhere
Conditional focusability
Blocking / overriding directional input
onArrowPress(direction, props) — return true to allow default navigation, false to block it. Useful for paginated rows, custom carousels, or refusing to leave the current container at edges.
useFocusable — params worth knowing
| Param | Purpose | |
|---|---|---|
focusable | Toggle whether element participates in navigation. Default true. | |
trackChildren | Enables hasFocusedChild. Has a perf cost — only enable when you read it. | |
saveLastFocusedChild | Container restores last focused child when re-entered. Default true. | |
isFocusBoundary / focusBoundaryDirections | Trap focus inside the container. | |
focusKey | Stable key for setFocus / doesFocusableExist. | |
preferredChildFocusKey | Which child gets initial focus when container is entered. | |
onEnterPress, onArrowPress, onFocus, onBlur | Event hooks. See docs/guides/event-callbacks.md. | |
extraProps | Arbitrary payload forwarded to callbacks (e.g. item id). |
Returned: ref (required), focusKey, focused (leaf), hasFocusedChild (container), focusSelf().
Top-level API surface
See docs/api-reference/SpatialNavigation.md for the full list and signatures.
Best practices
Do
- Always attach
refto a DOM element. - Wrap container children in
<FocusContext.Provider value={focusKey}>. - Enable
trackChildrenonly when you actually consumehasFocusedChild. - Use stable
focusKeys for elements you target programmatically. - Guard
setFocuscalls withdoesFocusableExist, especially around route changes / async data. - Use
isFocusBoundaryfor modals, drawers, and overlays. - Set
focusable: falseon disabled or hidden items rather than unmounting if they may toggle frequently.
Don't
- Don't read
focusedon a container — usehasFocusedChildinstead. - Don't omit
FocusContext.Provideron containers; children become unreachable from siblings. - Don't blindly call
setFocuson keys that may not be mounted (causes silent focus loss). - Don't generate
focusKeys that change on every render — focus state will be lost. - Don't enable
debug/visualDebugin production builds.
Debugging
Turn on diagnostics in init:
Common issues:
- Element won't focus —
refnot attached, orfocusable: false, or ancestor missingFocusContext.Provider. - Focus jumps to wrong neighbor — try a different
distanceCalculationMethod(corners/center/edges); enablevisualDebugto see hitboxes. - Focus lost on re-render —
focusKeyis unstable, or the previously focused node unmounted without a fallback. UsepreferredChildFocusKeyorsetFocusafter the new tree mounts. - Modal leaks focus — missing
isFocusBoundaryon the modal container.
More: docs/guides/debugging.md, docs/guides/performance.md.
Quick reference
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/norigin-spatial-navigation-react/SKILL.md
Popularity
- Repository stars
- 464
- Repository forks
- 112
- 7-day trend score
- 31
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/noriginmedia/norigin-spatial-navigation/norigin-spatial-navigation-react)