# react-auto-height

> Animated height support for `height: auto` elements (customizable `transition: height ...`)

Latest version **1.2.1** (published 2023-07-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-auto-height
pnpm add react-auto-height
yarn add react-auto-height
bun add react-auto-height
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2023-07-09 |
| First published | 2019-07-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 18.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | peter.hozak@gmail.com |
| Maintainers | aprillion |

## Links

- npm: https://www.npmjs.com/package/react-auto-height
- Repository: https://github.com/Aprillion/react-auto-height
- Homepage: https://github.com/Aprillion/react-auto-height#readme
- Issues: https://github.com/Aprillion/react-auto-height/issues
- npm.io page: https://npm.io/package/react-auto-height

## Recent versions

- 1.2.1 (latest) — 2023-07-09
- 1.2.0 — 2023-07-06
- 1.1.6 — 2022-02-19
- 1.1.5 — 2022-02-19
- 1.1.4 — 2022-01-22
- 1.1.3 — 2021-03-17
- 1.1.2 — 2021-03-13
- 1.1.1 — 2020-06-16
- 1.1.0 — 2020-06-16
- 1.0.5 — 2020-06-06
- 1.0.4 — 2020-06-06
- 1.0.3 — 2020-01-07
- 1.0.2 — 2019-12-09
- 1.0.1 — 2019-08-03
- 1.0.0 — 2019-08-03
- … 2 more at https://npm.io/package/react-auto-height/versions

## README

# 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](https://github.com/w3c/csswg-drafts/issues/626) for discussion.
This component implements a workaround inspired by the JavaScript technique from [CSS-Tricks](https://css-tricks.com/using-css-transitions-auto-dimensions/#article-header-id-5).

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

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

### Usage

```jsx harmony
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](./react-auto-height-in-action.gif)

### Development

```bash
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
```

---
_Source: https://npm.io/package/react-auto-height · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
