Color Picker

npm install --save @cevad-tokatli/color-picker

Installation

You can simply import the module and create a new object with it.

Properties

Color

  • Value Type : String
  • Default Value : #FF0000

The picker's initial value. You can specify the picker's initial value by setting a value to this property.

Show The Result

Color Format

  • Value Type : String
  • Default Value : hex

The format of the picker's value. ColorPicker supports three types of formats: HEX, RGB and HSL. If the opacity is less than 1, HSL is automatically converted to HSLA, HEX and RGB are automatically converted to RGBA.

Show The Result

Picker Style

  • Value Type : Number
  • Default Value : 0

ColorPicker comes with two style options. In the first style, the main box allows setting the saturation and lightness of the color and the second box allows setting the color; this is the default. In the second style, the main box allows setting the color and the second box allows setting the saturation and lightness.

Show The Result

Embed

  • Value Type : Boolean
  • Default Value : true

A boolean value that indicates whether the picker is shown when a button is clicked or embedded into the page directly. If it is false, a button is displayed that allows users to show the picker.

Show The Result

Size

  • Value Type : String
  • Default Value : medium

The picker's size. Three options available : Small, Medium, Large.

Show The Result

Allow Opacity

  • Value Type : Boolean
  • Default Value : true

A boolean value that indicates whether the opacity bar is visible or not.

Show The Result

Allow Clear Color

  • Value Type : Boolean
  • Default Value : false

A boolean value that indicates whether the clear color button (an eraser icon that allows clear selection) is visible or not.

Show The Result

Show Color Value

  • Value Type : Boolean
  • Default Value : true

A boolean value that indicates whether the color value box is visible or not. Color value box allows you to set a color by typing its name or code. All of the CSS color formats are supported (HEX, RGB, RGBA, HSL, HSLA).

Show The Result

Show Buttons

  • Value Type : Boolean
  • Default Value : true

A boolean value that indicates whether the buttons are visible or not. If the "embed" property is false, the only way to close the picker is to click on the Save or Cancel button.

Show The Result

Show Palette

  • Value Type : Boolean
  • Default Value : true

A boolean value that indicates whether the color table is visible or not. Color table allows you to show pre-defined colors. It is also possible for users to save colors for later use by adding this table.

Show The Result

Palette Colors

  • Value Type : String[]
  • Default Value : #FFFFB5, #FBBD87, #F45151, #7AEA89, #91C8E7, #8EB4E6, #B0A7F1

An array that holds the name or codes of the colors that will be shown in the Color Table as default.

Show The Result

Allow Palette Add Color

  • Value Type : Boolean
  • Default Value : true

A boolean value that indicates whether users can add a color to the color table or not.

Show The Result

Events

  • Open : Fires when the picker is open.
  • Close : Fires when the picker is closed.
  • Save : Fires when the selection is saved.
  • Cancel : Fires when the picker is closed without being saved.
  • Changed : Fires when the color is changed.
Show The Result

Methods

  • Get : Returns the current color.
  • Set : Changes the current color.
  • Show : Shows the picker.
  • Hide : Hides the picker.
  • Save : Saves the selection.
  • Cancel : Cancels the selection.
Show The Result