contrast
functionGet a contrasting color (black or white) for text readability. Uses WCAG relative luminance calculation to determine the best contrast.
Import
import { contrast } from '@modular/sdk';Notes
- returns
- '#000000' for light backgrounds, '#ffffff' for dark backgrounds
- throws
- Error if the color format is invalid
- example
- ```ts contrast('#ffffff') // => '#000000' contrast('#000000') // => '#ffffff' contrast('#ff0000') // => '#ffffff' ```