React Native MantineButtons

CopyButton

Copy text to clipboard

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

Usage

import { CopyButton, Button } from 'react-native-mantine';

<CopyButton value="Text to copy" timeout={2000}>
  {({ copied, copy }) => (
    <Button
      onPress={copy}
      color={copied ? 'green' : 'blue'}
    >
      {copied ? 'Copied!' : 'Copy'}
    </Button>
  )}
</CopyButton>

Props

PropTypeDefaultDescription
value (required)stringValue to copy to clipboard when copy function is called
timeoutnumber1000Copied state timeout in milliseconds - how long the copied state persists
children (required)(payload: { copied: boolean; copy: () => void }) => React.ReactNodeFunction that returns JSX based on current state - receives copied state and copy function

Source on GitHub · npm