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

CSS variable is invalid color #22

Open
artrayd opened this issue Dec 22, 2022 · 1 comment
Open

CSS variable is invalid color #22

artrayd opened this issue Dec 22, 2022 · 1 comment

Comments

@artrayd
Copy link

artrayd commented Dec 22, 2022

I'm using this code to get CSS variable color and check its contrast:

const titleColor = getComputedStyle(document.documentElement).getPropertyValue('--titleTextColor')

And every time I get this error:
Error: Invalid Color : #000000 at ColorContrastChecker.hexToLuminance

Can't figure out why that happens.

@artrayd artrayd changed the title Not a valid color CSS variable is invalid color Dec 22, 2022
@amaroyche
Copy link

amaroyche commented Feb 2, 2023

@artrayd Try trimming the value obtained from getPropertyValue

E.g. ...getPropertyValue('--titleTextColor').trim()

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