1.2.1 • Published 10 months ago

react-auto-height v1.2.1

Weekly downloads
68
License
MIT
Repository
github
Last release
10 months ago

AutoHeight

A React component that animates height: auto children when their content is changed, using CSS transitions.

Browsers do not support the transition to or from auto value for height and width, see W3C issue csswg-drafts#626 for discussion. This component implements a workaround inspired by the JavaScript technique from CSS-Tricks.

Use only if you have a trully dynamic content without deterministic height value. There is a small performance consideration (small when evaluated as an addition to the CSS transition itself) - after the first DOM paint that will follow a re-render, this components will cause multiple browser re-flows, to calculate the actual height, and then the CSS transition will start (estimated ~1ms on desktop for each AutoHeight, but YMMV).

Installation

npm i react-auto-height
# or
yarn add react-auto-height

Usage

import AutoHeight from 'react-auto-height'
...
let content = 'I can be different (or null) next render.'
return (
  <AutoHeight>
    {content}
  </AutoHeight>
)

See the Storybook in https://aprillion.github.io/react-auto-height for more examples.

animated preview

Development

yarn
yarn audit fix
yarn start
# make changes and manually test dynamic interactions in storybook
# update version in package.json
yarn build
git
npm publish
1.2.0

10 months ago

1.2.1

10 months ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago