How to color features specific HEX colors using conditional symbology with arcade

04-26-2023 10:50 AM
Labels (2)
New Contributor

Hi all, I'm a newbie to ArcGIS Pro, and most of the things I know I've either taught myself, read about online, or I remember from a bit of ArcMap training I had a few years ago. I have a hyper-specific question, and I'm struggling to find other community posts that even sort-of help. Apologies in advance if my jargon is wrong.

Basically, I have a feature class with a bunch of polygons (rooms within a building), and I am trying to display the symbology by the "Unit" that's assigned to that polygon. That much is simple. However, I have a pre-determined list of HEX color codes that are assigned to each unit, and I'd like to be able to use that list of color codes in Arc so that I can keep everything consistent. I can add the colors manually, but obviously that's super time consuming and doesn't help if I add more values and everything re-randomizes. I'd like to build an expression in Arcade that just automatically colors my map, as needed. I don't think Arc takes HEX color codes, so I can just convert to rgb, that's not a big issue. Below is my code that I've pieced together from other help forums, but it's not accomplishing what I need.


Like I mentioned before, I'm a complete newbie, and even newer to Arcade coding, so any and all help is appreciated. Thanks in advance!

Edit: I have ArcGIS Pro 2.7.0 if that helps!

0 Kudos
4 Replies
Occasional Contributor

Just to make sure, are you entering this expression in the Vary symbology by attribute section of the symbology pane under color?



If so, this help doc explains how the RGB code should be output. It needs to be a string, Attribute-driven color in symbology—ArcGIS Pro | Documentation with just rgb(r, g, b).


So your code as a starting point could look like this:

if($feature.UNIT == "unit A"){
   return "rgb(230, 149, 167)"



0 Kudos
New Contributor

Hi thank you so much! So when I run that code, it does correctly identify the right unit, but it changes the value and the label, when I want it to change the actual symbol. This is what I'm getting back:


and this is the color I'm expecting for the symbol:




0 Kudos
Esri Contributor

If you have color values stored in the attribute table, you can use symbol property connections to change the color of each feature based on attributes. The colors should be formatted like this:

For hex values: #eb4034

For rgb values: rgb(123,45,67)

Check the box to Allow symbol property connections in the Symbology pane, Vary symbology by attribute tab:


In the Primary symbology tab of the Symbology pane, select Single Symbol and click on the symbol to edit. 


Click the connection icon next to the fill color.


Pick the field containing the color values for each record, or create a more complex formula if you can't add hex values to the attribute table. You may also need to use a formula to format the color values if you don't have the # character in front of the hex values, or if the RGB values are split into 3 separate fields.


The fill colors are derived from the HEX field in the data:




0 Kudos
New Contributor II

Is it possible for the hex colours from the attribute table to be displayed in the Contents pane, so that they can be reflected in a layout legend?