React Native MantineData display

Spoiler

Content reveal with show more/less

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

Usage

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

const MyComponent = () => {
  const [shown, setShown] = useState(false);

  return (
    <>
      <Text>Visible content...</Text>
      <Collapse in={shown}>
        <Text>Hidden content revealed!</Text>
      </Collapse>
      <Button onPress={() => setShown(!shown)}>
        {shown ? 'Show less' : 'Show more'}
      </Button>
    </>
  );
};

Props

PropTypeDefaultDescription
children (required)React.ReactNodeContent that will be hidden under spoiler
maxHeight (required)number100Max height after which spoiler is shown
showLabelstring'Show more'Label for show button
hideLabelstring'Show less'Label for hide button
transitionDurationnumber200Transition duration in ms
expandedbooleanControlled expanded state
onExpandedChange(expanded: boolean) => voidCalled when expanded state changes
styleanyAdditional styles
testIDstringTest identifier used by testing frameworks

Source on GitHub · npm