Skip to content

Instantly share code, notes, and snippets.

@samk-dev
Created February 16, 2023 17:07
Show Gist options
  • Save samk-dev/412e590b8058408d7b3f102a6bd82572 to your computer and use it in GitHub Desktop.
Save samk-dev/412e590b8058408d7b3f102a6bd82572 to your computer and use it in GitHub Desktop.
get current background contrast && set font color accordingly
const contrast: string = r * 0.299 + g * 0.587 + b * 0.114 > 186 ? 'black' : 'white'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment