MCPcopy Index your code
hub / github.com/brunnolou/react-morph

github.com/brunnolou/react-morph @v0.3.6

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.3.6 ↗ · + Follow
50 symbols 100 edges 12 files 0 documented · 0% updated 13d ago★ 2,5477 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

React Morph ️🦋

Morphing UI transitions made simple

npm version size

Usage 🐛

npm install react-morph
# or
yarn add react-morph

Simple Example

  1. Create two states as you normally would (HTML + CSS).
  2. Wrap both in one <ReactMorph>
  3. Label the elements you wanna morph with from("a-key") and to("a-key")
  4. Perform the magic with go(0) or go(1)
import React from "react";
import ReactMorph from "react-morph";
<ReactMorph>
  {({ from, to, fadeIn, go }) => (



      <a onClick={() => go(1)}>
        <strong {...from("title")}>ReactMorph 🐛</strong>





Morphing transitions was never so easy!


      </a>




        <h1 {...to("title")}>ReactMorph 🦋</h1>



        <h2 {...to("description")}>Morphing transitions was never so easy!</h2>

        <a onClick={() => go(0)} {...fadeIn()}>
          Back
        </a>






  )}
</ReactMorph>

Features 🌟

  • Simplicity
  • No hardcoded absolute positions
  • All GPU accelerated props
  • No layout or paint browser rendering

Keep in mind

Caveats:

  • You need to remove extra whitespace, to match the real element's width, the solution is display: inline-block or a wrapping element to the content.
  • Margins are always tricky because they create extra white space. You can either wrap the content in another element and animate it or be sure to match both the margins in both states.
  • Sometimes it's necessary to create a placeholder element for the transition to avoid child distortion.
  • List items could be miscalculated; a simple solution is: list-style: none;.
  • Sometimes you need extra layers instead of nested children.
  • Avoid animating both the parent and children to avoid unpredicted results.

Live Demos

Sandbox

Edit j2rjln010w

TODO

Warning wip

  • [ ] Add a styled-components example
  • [ ] Recalculate positions on window resize
  • [ ] ? Optional portal for the second state ?

Core symbols most depended-on inside this repo

_interopRequireDefault
called by 9
lib/index.js
_toConsumableArray
called by 5
lib/index.js
hide
called by 4
lib/index.js
hide
called by 4
src/index.js
defineProperties
called by 2
lib/index.js
_possibleConstructorReturn
called by 2
lib/index.js
getBox
called by 2
lib/index.js
diffRect
called by 2
lib/index.js

Shape

Function 44
Class 4
Method 2

Languages

TypeScript100%

Modules by API surface

lib/all.min.js16 symbols
lib/index.js14 symbols
src/index.js10 symbols
examples/demo/src/registerServiceWorker.js4 symbols
src/util.js2 symbols
lib/util.js2 symbols
examples/demo/src/MultipleText.js1 symbols
examples/demo/src/App.js1 symbols

For agents

$ claude mcp add react-morph \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page