Skip to content
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

Disabling alpha in options does not remove it from the color string #41

Closed
rohanrichards opened this issue Jan 6, 2021 · 1 comment
Closed

Comments

@rohanrichards
Copy link

I need to remove alpha as an option for end users but would then expect the returned hex value to not include an alpha. My specific use case requires me to then send this data to a 3rd party API, which only validates 6 digit hex. This means I will now need to edit the hex value before I send it off.

It would make more sense to me that when alpha is set to false in the color picker it would return non-alpha colors (rgb instead of rgba, 6-digit hex instead of 8, etc.)

@Sphinxxxx
Copy link
Owner

In your onDone/onChange callback, you can use the printHex() method on the color object, which takes an "include alpha" parameter:

picker.onChange = function(color) {
    var hex6 = color.printHex(false);
    ...
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants