Socket
Socket
Sign inDemoInstall

react-native-color-palette

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-color-palette

A react native module for simple hex color selection


Version published
Weekly downloads
309
increased by37.95%
Maintainers
1
Install size
57.7 kB
Created
Weekly downloads
 

Readme

Source

React Native Color Palette.

A react native module for simple hex color selection

alt text

  • Controlled and Uncontrolled implementations
  • Simple to use

Getting started

Install the color picker

npm install react-native-color-palette --save
import ColorPalette from 'react-native-color-palette'

const UncontrolledColorPicker = () => (
  <ColorPalette
    onChange={color => alert(`Color selected: ${color}`)}
    defaultColor={'#C0392B'}
    colors={['#C0392B', '#E74C3C', '#9B59B6', '#8E44AD', '#2980B9']}
    title={"Uncontrolled Color Palette:"}
    icon={
      <Text></Text>︎
      // Icon can just be text or ASCII
    }
  />
)

const ControlledColorPicker = () => {
  let selectedColor = '#C0392B';
  return (
    <ColorPalette
      onChange={color => selectedColor = color}
      value={selectedColor}
      colors={['#C0392B', '#E74C3C', '#9B59B6', '#8E44AD', '#2980B9']}
      title={"Controlled Color Palette:"}
      icon={
        <Icon name={'check-circle-o'} size={25} color={'black'} />
      // React-Native-Vector-Icons Example
    }
  />)
}

Due to its Flexbox design, Color Palette will use the space you provide!

API

Props

Color Palette accepts properties below.

PropertyTypeNote
colorsArrayArray of hex color strings for rendering. ex) ['#C0392B', '#E74C3C', '#9B59B6', '#8E44AD', '#2980B9']
defaultColorStringDefines initial selected color in uncontrolled component.
valueStringDefines selected color in controlled component.
paletteStylesViewStyleStyles passed to color palette container
onChangeFunctionCallback with color (HEX string) as argument called when user confirms color selection.
titleStringText to display at the top of the palette.
titleStylesTextStyleInherits the default react-native Text Styles
iconText or IconSelector Text or Icon to be displayed in place of checkmark.
scaleToWindowBoolThis will automatically scale the palette to fit 6 per line and will scale up/down for iPads/ iPhones depending on window size

Keywords

FAQs

Last updated on 09 Nov 2019

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc