react-mixitup
TypeScript icon, indicating that this package has built-in type declarations

4.0.6 • Public • Published

react-mixitup

Animate the addition, removal and shuffling of elements in react.

GitHub Repo stars

Edit in CodeSandbox

Getting Started

Install react-mixitup

npm install --save react-mixitup

npm npm

See documentation

import { ReactMixitup } from 'react-mixitup';

function Example() {
  const [keys, setKeys] = React.useState([1,2,3]);

  return (
    <div style={{ height: 64 }}>
      <button onClick={() => {
        setKeys(keys[0] === 1 ? [3,2,1] : [1,2,3]);
      }}>
        Mixitup
      </button>
      <ReactMixitup
        keys={keys}
        renderCell={(key, style, ref) => (
          <div
            key={key}
            ref={ref}
            style={{
              // You must set the transition property here!
              transition: 'transform 300ms linear',
              ...style,
            }}
          >
            {key}
          </div>
        )}
        renderWrapper={(style, ref, cells) => {
          return (
            <div
              style={{
                transition: 'height 300ms ease',
                display: 'flex',
                ...style
              }}
              ref={ref}
            >
              {cells}
            </div>
          );
        }}
        dynamicDirection="horizontal"
        transitionDuration={300}
      />
    </div>
  )
}

License

MIT © ricsam

Package Sidebar

Install

npm i react-mixitup

Weekly Downloads

161

Version

4.0.6

License

MIT

Unpacked Size

204 kB

Total Files

13

Last publish

Collaborators

  • ricsam