How do i do switch case in color text , background etc

Hello ,

I'm trying to do a switch case in text color or background color but nothing work :frowning:

image

switch( ) {
    case {{ getAllAmlFailed.data.length > 0 }}:
        return "#E01E5A"
    case {{ getAllAmlFailed.data.length > 1 }}:
        return "#2EB67D"
    case {{ getAllAmlFailed.data.length > 1 }}:
        return "#116EE3"
}

Ternary work perfectly

{{ getAllKycFailed.data.length > 0 ? "#E01E5A" : "#2EB67D"}}

But i want to put an extra step like below

=== 0 ? GREEN
> 0 ? ORANGE
> 5 ? RED

thanks for the help

{{ getAllKycFailed.data.length > 0 ? 'orange : '' || getAllKycFailed.data.length === 0 ? 'green':'' || getAllKycFailed.data.length > 5 ? 'red':''}}

You can keep using || as an or operator but in your example above the > 0 orange and > 5 might conflict so you would want an && for the first ternary such as
{{(getAllKycFailed.data.length > 0 && getAllKycFailed.data.length < 5) ? 'orange : '' || and so on....}}

1 Like