-
-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set hex color from input #150
Comments
Ah, you might be looking for the Working with Colors section in the documentation? The TL;DR is each color picker has a Here's an example for hooking up an input element to a color picker's hexString value, and vice versa: <div id="colorPicker"></div>
<input id="hexInput"></input> var colorPicker = new iro.ColorPicker('#colorPicker');
var hexInput = document.getElementById('hexInput');
// whenever the input is committed, update the color picker's selected color from the value
hexInput.addEventListener('change', function() {
// (maybe do some regex validation here to make sure the input is a valid hex string first...)
colorPicker.color.hexString = this.value;
});
// whenever the color picker is updated, update the input value to match it
colorPicker.on('change', function(color) {
hexInput.value = color.hexString;
}); I also just quickly updated the Codepen demo to include an input element if you want to play around with it: |
Ahh thank you very much, I was trying to do colorPicker.color = '#FFFFFF'; |
No problem! Maybe I ought to improve the documentation there to make it a bit clearer. |
I have been looking through the documentation and I cannot find a way to set a color as the active color. For instance if I have an input box with an on change event and I enter #ffffff it does not update the selected color in the wheel.
If there is not a way can you implement that feature?
The text was updated successfully, but these errors were encountered: