Select to view content in your preferred language

Arcade supporting the font html tag

242
1
Jump to solution
06-02-2025 06:42 AM
JaysonLindahl
Frequent Contributor

I'm using the font html tag and the color attribute to return colored labels.  I've read online that arcade supports this html tag.  Here is my script:

var pct = $feature.PCT_NO;
var label = "Precinct " + $feature.PCT_NO;
var color = when(
  pct == 1, "#FF0000",
  pct == 2, "blue",
  pct == 3, "green",
  pct == 4, "orange",
  "black"
);
return "<font color='" + color + "'>" + label + "</font>";
 
What is returned on the map is not colored text, but the actual html text in black.
pctlabelsarcade.png
Tags (1)
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

Unfortunately, unlike ArcGIS Pro, you can't use formatting tags in a label in a web map. The way around that limitation would be to use a different label classes for each color.

For example, these labels were created using two label classes

Snag_6adc62.png

The Deep label class uses the expression 

if ($feature.Depth_ft > 30) return $feature.Depth_ft
 

while the Shallow label classes uses this expression

if ($feature.Depth_ft <= 30) return $feature.Depth_ft

View solution in original post

0 Kudos
1 Reply
KenBuja
MVP Esteemed Contributor

Unfortunately, unlike ArcGIS Pro, you can't use formatting tags in a label in a web map. The way around that limitation would be to use a different label classes for each color.

For example, these labels were created using two label classes

Snag_6adc62.png

The Deep label class uses the expression 

if ($feature.Depth_ft > 30) return $feature.Depth_ft
 

while the Shallow label classes uses this expression

if ($feature.Depth_ft <= 30) return $feature.Depth_ft
0 Kudos