Color
When to use
- Theme scales:
lighten/darken - Readable text:
contrastColor(bg)auto black/white - Convert:
hexToRgb/rgbToHex
Convert
ColorUtils.hexToRgb(hex)→{ r,g,b }ColorUtils.rgbToHex(r,g,b)→#rrggbb
Light/Dark
ColorUtils.lighten(hex, ratio)ColorUtils.darken(hex, ratio)
Contrast
ColorUtils.contrastColor(hex)→#000000or#ffffff
ts
import { ColorUtils } from 'nex-lib'
ColorUtils.hexToRgb('#ffcc00')
ColorUtils.rgbToHex(255, 204, 0)
ColorUtils.lighten('#333333', 0.5)
ColorUtils.darken('#cccccc', 0.5)
ColorUtils.contrastColor('#ffcc00')