Packages

@twind/core › DarkColor

@twind/core.DarkColor

Ƭ DarkColor<Theme>: (section: string, key: string, context: Context<Theme>, color: ColorValue) => ColorValue | Falsey

Type parameters

NameType
Themeextends BaseTheme

Type declaration

▸ (section, key, context, color): ColorValue | Falsey

Allows to return a dark color for the given light color.

js
{
  // 50 -> 900, 100 -> 800, ..., 800 -> 100, 900 -> 50
  darkColor: autoDarkColor
  // custom resolvers
  darkColor: (section, key, { theme }) => theme(`${section}.${key}-dark`) as ColorValue
  darkColor: (section, key, { theme }) => theme(`dark.${section}.${key}`) as ColorValue
  darkColor: (section, key, { theme }) => theme(`${section}.dark.${key}`) as ColorValue
  darkColor: (section, key, context, lightColor) => generateDarkColor(lightColor),
}

Or use the light color to generate a dark color

js
{
  darkColor: (section, key, context, color) => generateDark(color)
}
Parameters
NameTypeDescription
sectionstringthe theme section
keystringthe theme key within section — maybe an arbitrary value [...]
contextContext<Theme>the context
colorColorValuethe current color
Returns

ColorValue | Falsey

the dark color to use

Defined in

packages/core/src/types.ts:339