Collapse

Animate presence with slide down transition
Import

Usage

import { useState } from 'react';
import { Button, Collapse } from '@mantine/core';
function Demo() {
const [opened, setOpen] = useState(false);
return (
<>
<Button onClick={() => setOpen((o) => !o)}>
Toggle content
</Button>
<Collapse in={opened}>
{/* content... */}
</Collapse>
</>
);
}

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 { useState } from 'react';
import { Button, Collapse } from '@mantine/core';
function Demo() {
const [opened, setOpen] = useState(false);
return (
<>
<Button onClick={() => setOpen((o) => !o)}>
Toggle with linear transition
</Button>
<Collapse in={opened} transitionDuration={1000} transitionTimingFunction="linear">
{/* content... */}
</Collapse>
</>
);
}

Nested Collapse components