# @bianic-ui/collapse

> An accessible auto-height and collapse component for elements with variable (and dynamic) height

Latest version **0.1.0-alpha.2** (published 2020-09-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @bianic-ui/collapse
pnpm add @bianic-ui/collapse
yarn add @bianic-ui/collapse
bun add @bianic-ui/collapse
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0-alpha.2 |
| Published | 2020-09-03 |
| First published | 2020-09-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 33.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Muhammad Rafiul Ilmi Syarifudin |
| Maintainers | ilmimris |
| Keywords | react, accessible, react-component, collapse component, collapse, accordion, animate height, auto height |

## Links

- npm: https://www.npmjs.com/package/@bianic-ui/collapse
- Repository: https://gitlab.com/bia-design/bianic-ui
- Homepage: https://gitlab.com/bia-design/bianic-ui#readme
- Issues: https://gitlab.com/bia-design/bianic-ui/issues
- npm.io page: https://npm.io/package/@bianic-ui/collapse

## Dependencies (2)

- [@bianic-ui/utils](https://npm.io/package/@bianic-ui/utils.md) ^0.1.0-alpha.2
- [react-animate-height](https://npm.io/package/react-animate-height.md) 2.0.23

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.0-alpha.2 (latest) — 2020-09-03
- 0.1.0-alpha.1 — 2020-09-03

## README

# Collapse

The Collapse component is used to create regions of content that can
expand/collapse with a simple animation. It helps to hide content that's not
immediately relevant to the user.

## Installation

```sh
yarn add @bianic-ui/collapse

# or

npm i @bianic-ui/collapse
```

## Import component

```jsx
import { Collapse } from "@bianic-ui/collapse"
```

## Usage

```jsx
function SampleSpring() {
  const { isOpen, onToggle } = useDisclosure()
  return (
    <>
      <Button onClick={onToggle}>Click</Button>
      <Collapse isOpen={isOpen}>
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus
        terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer
        labore wes anderson cred nesciunt sapiente ea proident.
      </Collapse>
    </>
  )
}
```

## Changing the starting height

```jsx
function Example() {
  const [show, setShow] = React.useState(false)

  const handleToggle = () => setShow(!show)

  return (
    <>
      <Collapse startingHeight={20} isOpen={show}>
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus
        terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer
        labore wes anderson cred nesciunt sapiente ea proident.
      </Collapse>
      <Button size="sm" onClick={handleToggle} mt="1rem">
        Show {show ? "Less" : "More"}
      </Button>
    </>
  )
}
```

## Note

The `startingHeight` prop is passed directly to the `Transition` component which
uses the `react-transition-group` package under the hood, hence you won't be
able to pass Bianic UI's theme values as a value for the prop.

## With string as child

```jsx
function Example() {
  const { isOpen, onToggle } = useDisclosure()
  return (
    <>
      <button style={{ marginBottom: 10 }} onClick={onToggle}>
        Click
      </button>
      <Collapse isOpen={isOpen}>
        Lorem Ipsum is simply dummy text of the printing and typesetting
        industry. Lorem Ipsum has been the industry's standard dummy text ever
        since the 1500s, when an unknown printer took a galley of type and
      </Collapse>
    </>
  )
}
```

---
_Source: https://npm.io/package/@bianic-ui/collapse · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
