|
| 1 | +# Collapse |
| 2 | + |
| 3 | +The Collapse component is used to create regions of content that can |
| 4 | +expand/collapse with a simple animation. It helps to hide content that's not |
| 5 | +immediately relevant to the user. |
| 6 | + |
| 7 | +This component leverages [`@vueuse/motion`](https://motion.vueuse.org/) |
| 8 | + |
| 9 | +## Import |
| 10 | + |
| 11 | +```js |
| 12 | +import { CCollapse } from '@chakra-ui/vue-next'; |
| 13 | +``` |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +### Basic Usage |
| 18 | + |
| 19 | +```vue |
| 20 | +<template> |
| 21 | + <div> |
| 22 | + <c-button mb="4" variant-color="blue" @click="show = !show"> |
| 23 | + Toggle |
| 24 | + </c-button> |
| 25 | + <c-collapse :is-open="show"> |
| 26 | + Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus |
| 27 | + terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer |
| 28 | + labore wes anderson cred nesciunt sapiente ea proident. |
| 29 | + </c-collapse> |
| 30 | + </div> |
| 31 | +</template> |
| 32 | +
|
| 33 | +<script> |
| 34 | +export default { |
| 35 | + data () { |
| 36 | + return { |
| 37 | + show: false |
| 38 | + } |
| 39 | + } |
| 40 | +} |
| 41 | +</script> |
| 42 | +``` |
| 43 | + |
| 44 | +### Changing the startingHeight |
| 45 | + |
| 46 | +```vue |
| 47 | +<template> |
| 48 | + <div> |
| 49 | + <c-button mb="4" variant-color="blue" @click="show = !show"> |
| 50 | + Show {{ show ? 'Less' : 'More' }} |
| 51 | + </c-button> |
| 52 | + <c-collapse :starting-height="20" :is-open="show"> |
| 53 | + Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus |
| 54 | + terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer |
| 55 | + labore wes anderson cred nesciunt sapiente ea proident. |
| 56 | + </c-collapse> |
| 57 | + </div> |
| 58 | +</template> |
| 59 | +
|
| 60 | +<script> |
| 61 | +export default { |
| 62 | + data () { |
| 63 | + return { |
| 64 | + show: false |
| 65 | + } |
| 66 | + } |
| 67 | +} |
| 68 | +</script> |
| 69 | +``` |
| 70 | + |
| 71 | + |
| 72 | +## Props |
| 73 | + |
| 74 | +This component doesn't have any custom props. |
| 75 | + |
| 76 | +| Name | Type | Description | |
| 77 | +| ---------------- | --------- | ------------------------------------------------------------------------------------------------------------ | |
| 78 | +| isOpen | `boolean` | If `true`, the content will be visible | |
| 79 | +| animateOpacity | `boolean` | If `true`, the opacity of the content will be animated | |
| 80 | +| duration | `number` | The animation duration as it expands | |
| 81 | +| startingHeight | `number` | The height you want the content in it's collapsed state. Set to `0` by default | |
| 82 | +| endingHeight | `number` | The height you want the content in it's expanded state. Set to `auto` by default | |
| 83 | + |
| 84 | +## Events |
| 85 | + |
| 86 | +| Name | Payload | Description | |
| 87 | +| ---------- | --------- | ------------------------------------------------------------------------------------------------------------ | |
| 88 | +| `@entered` | `Event` | The event to be called when the collapse animation starts. | |
| 89 | +| `@left` | `Event` | The event to be called when the collapse animation ends. | |
0 commit comments