Skip to main content

The {{contrast_text_color}} helper returns a high-contrast text color for a given background color. Use it when your theme supports configurable brand or accent colors and you need readable text on top of them.

Example Code

For a dark background such as #15171A, the helper outputs:
For a light background such as #FFFFFF, the helper outputs:

Notes

  • Helps keep text readable on dynamic background colors
  • Works well with @site.accent_color
  • Falls back to #FFFFFF if the color is invalid or missing