v6.0.35

Collapse

Animate presence with slide down transition
Import

Usage

import { Button, Group, Text, Collapse, Box } from '@asuikit/core';
import { useDisclosure } from '@asuikit/hooks';
function Demo() {
const [opened, { toggle }] = useDisclosure(false);
return (
<Box maw={400} mx="auto">
<Group position="center" mb={5}>
<Button onClick={toggle}>Toggle content</Button>
</Group>
<Collapse in={opened}>
<Text>{/* ... content */}</Text>
</Collapse>
</Box>
);
}

Change transition

Set following props to control transition:

  • transitionDuration – duration in ms
  • transitionTimingFunction – timing function (ease, linear, etc.), defaults to ease
  • onTransitionEnd – called when transition ends (both open and close)
import { useDisclosure } from '@asuikit/hooks';
import { Button, Group, Text, Collapse, Box } from '@asuikit/core';
function Demo() {
const [opened, { toggle }] = useDisclosure(false);
return (
<Box maw={400} mx="auto">
<Group position="center" mb={5}>
<Button onClick={toggle}>Toggle with linear transition</Button>
</Group>
<Collapse in={opened} transitionDuration={1000} transitionTimingFunction="linear">
<Text>{/* ...content */}</Text>
</Collapse>
</Box>
);
}

Nested Collapse components

Collapse component props

NameTypeDescription
animateOpacity
boolean
Should opacity be animated
children *
ReactNode
Content that should be collapsed
in *
boolean
Opened state
onTransitionEnd
() => void
Called each time transition ends
transitionDuration
number
Transition duration in ms
transitionTimingFunction
string
Transition timing function