Skip to content

getModeByTheme ​

▸ getModeByTheme(color, thresholdValue?): "light" | "dark"

根据颜色获取对应的颜色模式

参数 ​

NameTypeDefault valueDescription
colorstringundefined颜色
thresholdValuenumber0.85亮度阈值

返回值 ​

"light" | "dark"

  • 'light' 表示颜色较浅,'dark' 表示颜色较深

示例

ts
const themeMode = getModeByTheme('#000000') // 'light'
const themeMode = getModeByTheme('#ffffff') // 'dark'

源码 ​

color.js