I want to color the different text input fields in a container that are being populated from a JSON with a Query depending on a respective value within that JSON (the confidence level of the extracted values).
I tried including it in the Query with JavaScript functions which apparently is not supported or at least did not work for me.
There are a couple ways of doing this, at it's most basic, you make the background colour of a textInput dynamic by using the style section of the component and putting in code like this (simplified)
If you need it to be more dynamic, based on the value in a JSON object, you could create a function that accepts a parameter for city, and structure it like this:
if(!type) return null //or 'white' or whatever you want
// Extract the confidence
const { confidence } = queryData.data.find( o => o.type === "City")
// Return colours as needed
if(confidence < .5) return 'mintgreen'
if(confidence < 1) return 'lightgreen'
if(confidence === 1) return 'darkgreen'
If you called this bgColour, you could change the function for the background to {{ bgColour({type: 'City'}) }} which would return 'lightgreen' in this case.