feat(reanimated): css transitions, focus pseudo selectors and outlines - #123
Merged
Conversation
RuudBurger
marked this pull request as ready for review
September 8, 2026 14:58
DouweBos
approved these changes
Sep 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reanimated 4 lets you drive focus styling from the style object itself, with css transitions and pseudo selectors:
:focuson the focusable,:focus-withinon an ancestor. That means a focus change doesn't wait for a React render, which matters on a TV. Lightning supported none of it, so apps had to keep a React-state fallback. This adds the css side to plugin-reanimated, plus outlines, so the focus ring can work the same way.A
CSSStylegets split the way reanimated splits it: the transition props become a Lightningtransitionon the node (opacity -> alpha, backgroundColor -> color, a transform expanded onto the axes it actually uses, border/outline colour -> shaderProps), and the per-propertydefault/:focus/:focus-withinvalues are swapped straight onto the node as focus moves. Resting values of pseudo props are held back from the rendered style and pushed imperatively, otherwise a re-render clobbers an active state.:focus-withincan't be read off the focus path (a plain wrapper View never appears in it), so one tracker per FocusManager walks up from the focused leaf onfocusPathChangedand only notifies the subscribers whose state changed. Outlines turned out to need no extra node: the border shader already draws outside the node withalign: 'outside'andgap, sooutlineWidth/outlineColor/outlineOffsetmap onto the element's own shader.Verified on the example app's new Pseudo Selectors page: the settled node values match the targets (
:focus-withinshift on the column, scale and colour on the card,border-align: outsidewith a 2px gap) and the ring cross-fades instead of snapping.Caveats:
:hover,:activeand:active-deepestare ignored with a dev warning (no pointer, and press state doesn't live on the element), and so are css animations, which I haven't built yet. A border and an outline can't share the one shader a node gets, so the border wins and dev says so. Also in here: a partial style push used to resolve its shader from the payload alone, so pushing a loneborderColororoutlineColorrebuilt the shader without its width; it now resolves against the merged style. And the example app didn't boot on main (reanimated pullsreact-native-is-edge-to-edge, whosemoduleentry is CJS), so there's a small stub for that :hide: