A function to calculate the brightness of a color by its hex code and determine whether it is light or dark.
Install the package:
# pnpm
pnpm add @unmilley/luminance
# yarn
yarn add @unmilley/luminance
# npm
npm install @unmilley/luminance
Import:
import { luminance } from "@unmilley/luminance";
luminance("#000000"); // 'white'
luminance("ffffff"); // 'black'
luminance("808"); // 'white'
local development
MIT. Made with 💛