1.0.9 • Published 3 years ago

@achtaitaipai/color-picker v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Color Picker

Simple color-picker custom element


Usage

Install the package using npm :

npm install @achtaitaipai/color-picker

Import it in your script

import @achtaitaipai/color-picker

Use the custom element in your html using

<color-picker></color-picker>.

<color-picker confirm-label="Ok" cancel-label="Cancel" pallet='["#ff0000","#1D2B53","#7E2553"]'></color-picker>

Define style

color-picker {
	position: fixed;
	width: 200px;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
}

Open the color-picker with open() and listen change with color-change

const clrpckr = document.querySelector('color-picker')
clrpckr.open()

pckr.addEventListener('color-change', e => {
	console.log(e.detail)
})

Doc

Attributes

NameTypeExample
palletarray"['#ff0000','#1D2B53']"
confirm-labelstring"Ok"
cancel-labelstring"Cancel"

Methods

NameDescription
openopen the color picker
closeclose the color picker

CSS Variables

Namedefaultdescription
--bg#3f3e3ebackground color
--bg-input#282828background color of text input and buttons
--font-color#fffffffont color
--bg-error#7b0000background color of text input when error

Properties

NameTypeExample
valuestring#ff0000
1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.0

3 years ago