React Native MantineMiscellaneous

Collapse

Smooth collapsible content

Import: import { Collapse } from 'react-native-mantine';

Usage

import { useState } from 'react';
import { Collapse, Button, Text, Paper } from 'react-native-mantine';

const MyComponent = () => {
  const [opened, setOpened] = useState(false);

  return (
    <>
      <Button onPress={() => setOpened(!opened)}>
        Toggle Content
      </Button>

      <Collapse in={opened}>
        <Paper p="md">
          <Text>Collapsible content here</Text>
        </Paper>
      </Collapse>
    </>
  );
};

Props

PropTypeDefaultDescription
children (required)React.ReactNodeContent that should be collapsed
in (required)booleanOpened state
transitionDurationnumber200Transition duration in ms
transitionTimingFunction'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out''ease'Transition timing function
onTransitionEnd() => voidCalled when transition ends
animateOpacitybooleantrueIf true, content opacity is animated together with its height
styleanyAdditional styles
testIDstringTest identifier used by testing frameworks

Source on GitHub · npm