
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
github.com/instea/react-native-color-picker
React Native implementation of color picker for both Android and iOS.
Install the color picker
npm install react-native-color-picker --save
And use it in your application
import { ColorPicker } from 'react-native-color-picker'
const Picker = () => (
<ColorPicker
onColorSelected={color => alert(`Color selected: ${color}`)}
style={{flex: 1}}
/>
)
Color picker will use space you provide. Therefore it is necessary to provide styles that will determine picker's size.
We provide two types of color picker - holo (default) and triangle color picker. Both has the same API so that they are interchangable. Just import it and use it the same way:
import { ColorPicker, TriangleColorPicker } from 'react-native-color-picker'
ColorPicker | TriangleColorPicker |
---|---|
![]() | ![]() |
Color pickers accepts properties below. Each property which define color is represented as a color string.
Property | Type | Note |
---|---|---|
color | `String | HSV` |
defaultColor | String | Defines initial selected color in uncontrolled component. |
oldColor | String | Old color to be used for visual comparision. If it is not defined, whole circle is representing selected color. |
style | Style | Styles passed to color picker container |
onColorSelected | Function | Callback with color (HEX string) as argument called when user confirms color selection. |
onColorChange | Function | Callback called each time when color is changed. Used in controlled component. Argument is color in HSV representation (see below) |
onOldColorSelected | Function | Callback with color (HEX string) as argument called when user selects old color. |
When using color picker as a controlled component you should always use HSV color representation to avoid conversion from/to HEX or RGB. HSV color representation is an object literal with properties:
{
h: number, // <0, 360>
s: number, // <0, 1>
v: number, // <0, 1>
}
To utilize HSV -> HEX/RGB conversion we provide helper functions:
import { toHsv, fromHsv } from 'react-native-color-picker'
toHsv('blue') // { h: 24, s: 1, v: 1 }
fromHsv({ h: 200, s: 0.4, v:0.4 }) // #3d5866
ScrollView
due to touch event interference.Our implementation was inspired by Android Holo ColorPicker
FAQs
Unknown package
Did you know?
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.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.