getTextColorOn

A utility function to get the text color that belongs on a background color.

Syntax

getTextColorOn(colorShade)(props)

Usage

const Component = styled.div`
  color: ${getTextColorOn('primary.base')};
`

Arguments

ArgumentTypeDescription
colorShadeStringThe full palette color and shade expressed in dot notation, example primary.base.
propsObjectThe props passed to the component, must contain a theme prop.

Example

const TextDemo = styled.div`
  color: ${getTextColorOn('primary.base')};
  background-color ${getPaletteColor('primary.base')};
`
Lightest text color
<TextDemo>Lightest text color</TextDemo>

Pass a full palette color and shade to return the text color that belongs on that color. The above example would return text.lightest while getTextColorOn('primary.light') would return text.base.