React Native MantineData display

ColorSwatch

Color preview swatch

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

Usage

import { ColorSwatch, Group } from 'react-native-mantine';

<Group spacing={8}>
  <ColorSwatch color="#228be6" />
  <ColorSwatch color="#fa5252" />
  <ColorSwatch color="#40c057" />
</Group>

// With onPress and custom size
<ColorSwatch
  color="#228be6"
  size={40}
  onPress={() => console.log('Color selected')}
/>

Props

PropTypeDefaultDescription
color (required)stringSwatch background color in any valid format (hex, rgb, rgba, etc.)
sizenumber25Width and height of the swatch in pixels
radiusnumber | "xs" | "sm" | "md" | "lg" | "xl""xl"Key of theme.radius or number to set border-radius in pixels
childrenReact.ReactNodeColorSwatch children, for example check icon or other overlay content
withShadowbooleantrueDetermines whether the swatch should have inner shadow
onPress() => voidCalled when swatch is pressed - makes swatch interactive
styleViewStyleAdditional styles to apply to the swatch container

Source on GitHub · npm