|
| 1 | +--- |
| 2 | +title: Collapse |
| 3 | +description: Collapse component |
| 4 | +version: 2.0+ |
| 5 | +--- |
| 6 | +# Collapse |
| 7 | + |
| 8 | +The Collapse component is used to create regions of content that can expand/collapse with a basic animation. It helps to hide content that's not immediately relevant to the user. |
| 9 | + |
| 10 | +This component leverages [animejs](https://animejs.com/){target="_blank"}, and composes the Box component. |
| 11 | + |
| 12 | +## Import |
| 13 | + |
| 14 | +```js |
| 15 | +import { CCollapse } from "@chakra-ui/vue-next"; |
| 16 | +``` |
| 17 | + |
| 18 | +## Usage |
| 19 | + |
| 20 | +::showcase |
| 21 | +:simple-collapse{width=full} |
| 22 | +:: |
| 23 | + |
| 24 | + |
| 25 | +```html |
| 26 | +<CBox> |
| 27 | + <CButton mb="4" variant-color="blue" @click="show = !show"> |
| 28 | + Toggle |
| 29 | + </CButton> |
| 30 | + <CCollapse :is-open="show"> |
| 31 | + Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's |
| 32 | + standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a |
| 33 | + type specimen book. |
| 34 | + </CCollapse> |
| 35 | +</CBox> |
| 36 | +``` |
| 37 | + |
| 38 | +## Change the Starting Height |
| 39 | + |
| 40 | +::showcase |
| 41 | +:height-collapse{width=full} |
| 42 | +:: |
| 43 | + |
| 44 | + |
| 45 | +```html |
| 46 | +<CBox> |
| 47 | + <CButton mb="4" variant-color="blue" @click="show = !show"> |
| 48 | + Show {{ show ? 'Less' : 'More' }} |
| 49 | + </CButton> |
| 50 | + <CCollapse :is-open="show" :starting-height="20"> |
| 51 | + Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's |
| 52 | + standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a |
| 53 | + type specimen book. |
| 54 | + </CCollapse> |
| 55 | +</CBox> |
| 56 | +``` |
| 57 | + |
| 58 | +## Props |
| 59 | + |
| 60 | +This component doesn't have any custom props. |
| 61 | + |
| 62 | +| Name | Type | Description | |
| 63 | +|----------------|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------| |
| 64 | +| isOpen | `boolean` | If `true`, the content will be visible | |
| 65 | +| animateOpacity | `boolean` | If `true`, the opacity of the content will be animated | |
| 66 | +| duration | `number` | The animation duration as it expands | |
| 67 | +| startingHeight | `number` | he height you want the content in it's collapsed state. Set to `0` by default | |
| 68 | +| endingHeight | `number` | The height you want the content in it's expanded state. Set to `auto` by default | |
| 69 | +| easing | `string` | Add easing function for entering and leaving state. Accepts easing props from [animejs](https://animejs.com/documentation/#linearEasing){target="_blank"}. Set to `easeInOutSine` by default. | |
| 70 | + |
| 71 | +## Events |
| 72 | + |
| 73 | +| Name | Payload | Description | |
| 74 | +|----------------|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------| |
| 75 | +| `@start` | `Event` | The event to be called when the collapse animation starts. | |
| 76 | +| `@finish` | `Event` | The event to be called when the collapse animation ends. | |
0 commit comments