React Native MantineInputs

ColorPicker

Pick a color with saturation, hue and alpha controls

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

Usage

import { ColorPicker } from 'react-native-mantine';

// Hex picker
<ColorPicker value={value} onChange={setValue} />

// Alpha slider with rgba output
<ColorPicker format="rgba" onChangeEnd={setValue} />

// Swatches-only palette
<ColorPicker
  withPicker={false}
  swatches={['#fa5252', '#228be6', '#12b886']}
  swatchesPerRow={7}
  onColorSwatchClick={(color) => console.log(color)}
/>

// HueSlider and AlphaSlider are also exported standalone
import { HueSlider, AlphaSlider } from 'react-native-mantine';

Props

PropTypeDefaultDescription
valuestringColor value for controlled component, in one of the supported formats
defaultValuestringDefault value for uncontrolled component
onChange(value: string) => voidCalled when color changes
onChangeEnd(value: string) => voidCalled when the user stops dragging or picks a swatch
onColorSwatchClick(color: string) => voidCalled when a color swatch is pressed
format'hex' | 'hexa' | 'rgb' | 'rgba' | 'hsl' | 'hsla'"hex"Color format, alpha slider is shown for hexa, rgba and hsla
withPickerbooleantrueDetermines whether the saturation/hue/alpha pickers should be displayed
swatchesstring[]Predefined colors displayed as swatches under the pickers
swatchesPerRownumber7Number of swatches per row
size'xs' | 'sm' | 'md' | 'lg' | 'xl'"md"Controls the size of the pickers
fullWidthbooleanfalseDetermines whether the picker should take 100% of available width
saturationLabelstring"Saturation"Saturation area accessibility label
hueLabelstring"Hue"Hue slider accessibility label
alphaLabelstring"Alpha"Alpha slider accessibility label

Source on GitHub · npm