React Native MantineInputs

ColorInput

Color value input with picker bottom sheet

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

Usage

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

<ColorInput
  label="Brand color"
  placeholder="#228be6"
  value={value}
  onChange={setValue}
  format="hex"
  swatches={['#fa5252', '#228be6', '#12b886']}
  closeOnColorSwatchClick
/>

// Picker only, no typing
<ColorInput disallowInput defaultValue="#be4bdb" />

Props

PropTypeDefaultDescription
valuestringColor value for controlled component
defaultValuestringDefault value for uncontrolled component
onChange(value: string) => voidCalled when the color changes
onChangeEnd(value: string) => voidCalled when the user stops interacting with the picker
format'hex' | 'hexa' | 'rgb' | 'rgba' | 'hsl' | 'hsla'"hex"Color format used by the picker and produced values
withPickerbooleantrueDetermines whether the color picker should be displayed in the dropdown
withPreviewbooleantrueDetermines whether the current color preview swatch should be displayed on the left
disallowInputbooleanfalsePrevents typing, the dropdown opens when the input is pressed
fixOnBlurbooleantrueReverts to the last valid value on blur when the typed value is invalid
swatchesstring[]Predefined colors displayed as swatches in the dropdown
swatchesPerRownumber7Number of swatches per row
closeOnColorSwatchClickbooleanfalseCloses the dropdown when a swatch is pressed
pickerButtonLabelstring"Open color picker"Accessibility label of the button that opens the dropdown
disabledbooleanDisables the input and the dropdown
labelReact.ReactNodeInput label, inherited from TextInput
descriptionReact.ReactNodeInput description, inherited from TextInput
errorReact.ReactNodeError message, inherited from TextInput

Source on GitHub · npm