Skip to content

Contrasting from Array

What It Does

The Contrasting from Array node evaluates multiple colors against a background and returns the first one that meets a contrast threshold. If no color is sufficiently contrasting, it returns the one with the highest contrast.

Inputs

NameDescriptionTypeRequired
ColorsArray of color options to evaluateList of ColorsYes
BackgroundThe background color to test contrast againstColorNo
AlgorithmContrast calculation method (APCA is default)StringNo
ThresholdMinimum contrast value considered sufficient (default: 60)NumberNo

Outputs

NameDescriptionType
ColorThe selected color with best/sufficient contrastColor
SufficientWhether the selected color meets the thresholdYes/No
ContrastThe contrast ratio of the selected colorNumber
IndexThe position of the selected color in the original arrayNumber

How to Use It

  1. Drag the Contrasting from Array node into your graph.
  2. Drag a Scale colors node and set the input color as #0044FF
  3. Connect the output of Scale colors node to the "Colors" input.
  4. Set the "Background" to the surface color where the colors will appear. Default is set as #FFFFFF
  5. Adjust the "Threshold" to your desired minimum contrast level. Default is set as 60.
  6. Select the "Algorithm" method. Default is APCA.
  7. The node outputs the first color that meets the threshold, or the one with highest contrast.
  8. The output "Color" is #3C6BED ("Index" of 4 in the input array) because it gives a "Contrast" of 71.59 which is more than the "Threshold" value of 60.

Tips

  • Arrange your colors array with preferred options first, as the node returns the first sufficient color.
  • The index output is useful for tracking which color was selected from the array.

See Also

Use Cases

  • Theme Color Selection: Find an appropriate color from a theme palette for a specific background.
  • Text Color Optimization: Automatically select the most readable text color from a set of brand options.
  • Accessible UI Components: Choose colors that meet accessibility requirements from a predefined set.