Accessibility for any React component.
Build a parallel DOM accessibility tree for UIs that render outside the DOM: WebGL canvases, react-three-fiber scenes, Pixi stages, game UIs. Components declare accessible markup wherever they live in the scene graph; it tunnels into a screenreader-friendly DOM tree that mirrors the scene.
npm i a11y-tree fiber-tunnel
Requires React 19.2 or later.
<A11yTreeProvider>:
Root provider. Wrap your canvas (and <A11yTreeRenderer>) in it.
<A11yTreeRenderer>:
Renders the accessibility tree into the DOM, visually hidden by default.
<FiberAnchor>
(from fiber-tunnel):
Wrap each nested React root that holds a11y content (an r3f <Canvas>, a second canvas).
<A11yTreeElement>:
Tunnels accessible DOM markup from a scene component into the tree.
<A11yTreeContainer>:
Wraps a subtree, so nested a11y tree components land inside.
<A11yTreeProvider>
<FiberAnchor>
<Canvas fallback={<A11yTreeRenderer />}>
<A11yTreeContainer
render={(content) => (
<div role="listbox" aria-label="Hand">
{content}
</div>
)}
>
<Card3D>
<A11yTreeElement>
<div role="option">Ace of Spades</div>
</A11yTreeElement>
</Card3D>
</A11yTreeContainer>
</Canvas>
</FiberAnchor>
</A11yTreeProvider>
The a11y tree mirrors the scene hierarchy:
<div role="listbox" aria-label="Hand">
<div role="option">Ace of Spades</div>
</div>
For lists whose items move: nodes keep their state, DOM node and focus across reorders and moves between lists.
<A11yTreeMirror>:
Renders ordered lists of keyed nodes.
<A11yTreeOutlet>:
A list's place in the tree, from useA11yTreeOutlet.
<A11yTreeMirrorIn>:
Routes scene content into a node.
const renderHand = (List) => <List as="ul" aria-label="Hand" />;
const hand = useA11yTreeOutlet();
const nodes = cards.map((card) => ({ key: card.id, props: card }));
<A11yTreeMirror
lists={[{ id: "hand", outlet: hand, nodes, render: renderHand }]}
nodeElement="li"
>
<A11yTreeOutlet outlet={hand} />
{cards.map((card) => (
<A11yTreeMirrorIn key={card.id} nodeKey={card.id}>
<Card3D card={card} />
</A11yTreeMirrorIn>
))}
</A11yTreeMirror>;
renderNode, or add native listeners to the list.render and renderNode stable to avoid re-renders.A11yTreeRenderer catches errors from tunneled content and shows a dismissible dialog;
its fallback prop replaces the dialog.
The tree is built on fiber-tunnel, which orders content by React tree position.
See examples on the documentation website
pnpm install
pnpm dev
This project uses React Compiler.