https://github.com/bendc/color-picker
Web component color picker
https://github.com/bendc/color-picker
Last synced: about 1 year ago
JSON representation
Web component color picker
- Host: GitHub
- URL: https://github.com/bendc/color-picker
- Owner: bendc
- License: mit
- Created: 2016-09-26T17:35:48.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-09-26T17:49:07.000Z (almost 10 years ago)
- Last Synced: 2025-03-26T05:11:30.183Z (over 1 year ago)
- Language: JavaScript
- Homepage: http://playground.deaxon.com/js/color-picker
- Size: 4.88 KB
- Stars: 43
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Usage
Insert the custom element and the library in your document:
```html
Example
```
Listen for the `color-change` event to get the selected color:
```javascript
const picker = document.querySelector("color-picker");
picker.addEventListener("color-change", () => {
const { state } = picker;
console.log(state); // => object containing the current rgb, hsb and hex values
});
```
Please note this component is based on the [Shadow DOM v1
spec](http://w3c.github.io/webcomponents/spec/shadow/) which might require a
[polyfill](https://github.com/webcomponents/shadydom) for older browsers.