Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

reanimated-color-picker

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reanimated-color-picker

Pure JavaScript color picker for react-native

  • 0.0.28-beta
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15K
decreased by-4.24%
Maintainers
1
Weekly downloads
 
Created
Source

:red_circle: :green_circle: :large_blue_circle:

Reanimated Color Picker

npm GitHub GitHub issues Platform

- Pure JavaScript color picker for react-native.

- Highly customizable.

- Supports IOS, Android, Expo and Web platforms.

- Supports right to left (RTL) layout.

:warning: :warning: Warning :warning: :warning:

  • This project is still in beta stage.
  • Some properties may change.

Example_1 Example_2 Example_3 Example_4

:small_blue_diamond: Table of contents

:small_blue_diamond:Prerequisites

:small_blue_diamond:Installation

Note First we need to install react-native-gesture-handler(>=2.0.0) and react-native-reanimated(>=2.0.0),

  • Open a Terminal in the project root and run:
npm i reanimated-color-picker

:small_blue_diamond:Usage

import React, { useState } from 'react';
import { Button, Modal, View } from 'react-native';

import ColorPicker, { Panel1, Swatches, Preview, OpacitySlider, HueSlider } from 'reanimated-color-picker';

export default function App() {
  const [showModal, setShowModal] = useState(false);

  const onSelectColor = ({ hex }) => {
    // do something with the selected color
    console.log(hex);
  };

  return (
    <View style={styles.container}>
      <Button title='Color Picker' onPress={() => setShowModal1(true)} />

      <Modal visible={showModal}>
        <ColorPicker value='red' onComplete={onSelectColor}>
          <Preview />
          <Panel1 />
          <HueSlider />
          <OpacitySlider />
          <Swatches />
        </ColorPicker>

        <Button title='Ok' onPress={() => setShowModal(false)} />
      </Modal>
    </View>
  );
}

:small_blue_diamond:API

:small_red_triangle:ColorPicker Wrapper

  • The ColorPicker Wrapper is responsible for managing the built-in components.

  • It has the following props:

:small_orange_diamond:value

  • The initial value of the color picker.
  • Accepts 'hex', 'rgb', 'rgba', 'hsl', 'hsla' and named color formats.
  • type: string
  • default: '#418181'

:small_orange_diamond:slidersThickness

  • A global style to change the thickness of all descendant sliders components.
  • The thickness is the slider's width in case of vertical orientation and height in case of horizontal orientation.
  • type: number
  • default: 25

:small_orange_diamond:thumbsSize

  • A global style to change the thumb size of all descendant sliders components.
  • type: number
  • default: 35

:small_orange_diamond:style

  • Color picker's container style.
  • If you want to change the width using the width property.
  • type: StyleProp<ViewStyle>

Note some style properties will be overwritten.

:small_orange_diamond:onChange

  • Called every time the color value changed.
  • The passed color object has the following properties: hex, rgb, rgba, hsl and hsla
  • type: (color: object) => void
  • default: null

:small_orange_diamond:onComplete

  • Called when the user releases the slider handle or when a swatch is clicked.
  • The passed color object has the following properties: hex, rgb, rgba, hsl and hsla
  • type: (color: object) => void
  • default: null

:small_red_triangle:Built-in Components

:small_orange_diamond:<Preview />

preview

  • The preview of the selected and the initial color.
PropertyTypeDefaultDescription
colorFormatstring'hex'preview color text format: 'hex', 'rgb', 'rgba', 'hsl', 'hsla', 'hsv' or 'hsva'
hideInitialColorbooleanfalsehide the initial color preview part
hideTextbooleanfalsehide preview color texts
styleStyleProp<ViewStyle>/preview container style
textStyleStyleProp<TextStyle>/preview text style

Note some style properties will be overwritten.

:small_orange_diamond:<PreviewText />

  • A React Native <Text> component that displays the preview color text.
PropertyTypeDefaultDescription
colorFormatstring'hex'preview color text format: 'hex', 'rgb', 'rgba', 'hsl', 'hsla', 'hsv' or 'hsva'
styleStyleProp<TextStyle>/preview text style

:small_orange_diamond:<Panel1 />

panel1

  • A square-shaped slider (adobe style) used for changing the color's brightness and saturation.

Note you need to add <HueSlider /> alongside with it.

PropertyTypeDefaultDescription
thumbSizenumber35panel's handle (thumb) size (height*width)
styleStyleProp<ViewStyle>/panel's container style

Note some style properties will be overwritten.

:small_orange_diamond:<Panel2 />

panel2

  • A square-shaped slider (windows style) used for changing the color's hue and saturation.

Note you need to add <BrightnessSlider /> alongside with it.

PropertyTypeDefaultDescription
thumbSizenumber35panel's handle (thumb) size (height*width)
styleStyleProp<ViewStyle>/panel's container style

Note some style properties will be overwritten.

:small_orange_diamond:<HueSlider />

hue

  • A slider to change color's hue.
PropertyTypeDefaultDescription
thumbSizenumber35hue slider handle (thumb) size (height*width)
ringColorstring#fffthe color of the ring around the slider handle
reversebooleanfalsereverse slider direction
verticalbooleanfalsechange slider orientation
styleStyleProp<ViewStyle>/hue slider container style

Note some style properties will be overwritten.

:small_orange_diamond:<SaturationSlider />

saturation

  • A slider to change color's saturation.
PropertyTypeDefaultDescription
thumbSizenumber35saturation slider handle (thumb) size (height*width)
ringColorstring#fffthe color of the ring around the slider handle
reversebooleanfalsereverse slider direction
verticalbooleanfalsechange slider orientation
styleStyleProp<ViewStyle>/saturation slider container style

Note some style properties will be overwritten.

:small_orange_diamond:<BrightnessSlider />

brightness

  • A slider to change color brightness.
PropertyTypeDefaultDescription
thumbSizenumber35brightness slider handle (thumb) size (height*width)
ringColorstring#fffthe color of the ring around the slider handle
reversebooleanfalsereverse slider direction
verticalbooleanfalsechange slider orientation
styleStyleProp<ViewStyle>/brightness slider container style

Note some style properties will be overwritten.

:small_orange_diamond:<OpacitySlider />

opacity

  • A slider to change color's opacity.
PropertyTypeDefaultDescription
thumbSizenumber35opacity slider handle (thumb) size (height*width)
ringColorstring#fffthe color of the ring around the slider handle
reversebooleanfalsereverse slider direction
verticalbooleanfalsechange slider orientation
styleStyleProp<ViewStyle>/opacity slider container style

Note some style properties will be overwritten.

:small_orange_diamond:<Swatches />

swatches

  • A list of colored swatches is used for quick color selection.
PropertyTypeDefaultDescription
colorsstring[]material colorscustom swatches colors
styleStyleProp<ViewStyle>/swatches container style
swatchStyleStyleProp<ViewStyle>/swatch style

Note some style properties will be overwritten.

:small_blue_diamond:Example

:small_blue_diamond:License

Keywords

FAQs

Package last updated on 05 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc