Select to view content in your preferred language

Use of Bold in Arcade Expressions

1752
2
Jump to solution
08-15-2024 03:56 PM
Labels (1)
JennHat
Emerging Contributor

Hello,

I'm displaying a number of attributes in a list. I want to bold the attribute titles like so:

Location ID: 110611
Description: Yorktown Shops 
Facility Status: Operating
Asset Code: 7100

Because there's 20+ attributes that will be displayed, I don't want to use HTML codes in a text box and create 20+ expressions. I'm also producing it for someone else to copy and paste the code, so I can't just make it in Pro. 

I tried to use the following that I saw in another post, but it kept thinking it was a dictionary and it made a table, with the bold tags displaying as text. Any ideas?

 

var Location = $feature.LOCATION;
var Description = $feature.DESCRIPTION;
var Facility_Status= Proper($feature.STATUS);
var Asset_Code = $feature.ASSET_CODE;


return {
  type : "text",
  text : `<b>Location ID:</b> ${Location}`
}

 

 

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

This seems to work just fine over here.

jcarlson_0-1723772116956.png

 

You could try using inline style tags, see if that works? I like using <style> anyway, because you can modify the text a lot more.

jcarlson_1-1723772212941.png

If you want to keep the code concise, and you're just making certain text bold, you could try a custom function, too. Maybe overkill just for bolding the text, but if you are doing something with a lot of custom style tagging, it's helpful to put the styling in a function or a variable so that you can adjust everything all at once.

function makeItBold(label, attribute){
  return `<span style="font-weight:bold">${label}</span>: ${attribute}`
}

return {
  type: 'text',
  text: `${makeItBold('Location ID', $feature['LOCATION'])}<br>
${makeItBold('Description', $feature['DESCRIPTION'])}`
}
- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

This seems to work just fine over here.

jcarlson_0-1723772116956.png

 

You could try using inline style tags, see if that works? I like using <style> anyway, because you can modify the text a lot more.

jcarlson_1-1723772212941.png

If you want to keep the code concise, and you're just making certain text bold, you could try a custom function, too. Maybe overkill just for bolding the text, but if you are doing something with a lot of custom style tagging, it's helpful to put the styling in a function or a variable so that you can adjust everything all at once.

function makeItBold(label, attribute){
  return `<span style="font-weight:bold">${label}</span>: ${attribute}`
}

return {
  type: 'text',
  text: `${makeItBold('Location ID', $feature['LOCATION'])}<br>
${makeItBold('Description', $feature['DESCRIPTION'])}`
}
- Josh Carlson
Kendall County GIS
0 Kudos
JennHat
Emerging Contributor

Thanks! Turns out, I was putting it in the wrong spot-- I was using the Attribute Expressions instead of just adding Arcade code as content to the pop up. It worked once I did that. Thanks for providing options!

0 Kudos