<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Help changing the icons in the LayerList Widget in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/help-changing-the-icons-in-the-layerlist-widget/m-p/1593711#M86652</link>
    <description>&lt;P&gt;I'm looking to add custom icons to the layerList widget. As you can see below, I achieved occasional success by following the documentation example here&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/widgets-layerlist-actions/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/sample-code/widgets-layerlist-actions/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GabrielaBuraglia_0-1741576965470.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/127468i126A911032F76666/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GabrielaBuraglia_0-1741576965470.png" alt="GabrielaBuraglia_0-1741576965470.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I use an async&amp;nbsp;&lt;SPAN&gt;listItemCreatedFunction, with an &lt;/SPAN&gt;&lt;SPAN&gt;await&lt;/SPAN&gt; &lt;SPAN&gt;item&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;layer&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;when&lt;/SPAN&gt;&lt;SPAN&gt;(); and then I c&lt;/SPAN&gt;&lt;SPAN&gt;reate a custom DOM element to hold the item.title with the custom icon. However, I can't make it work consistently. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any suggestions? Thanks in advance.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Mar 2025 03:30:51 GMT</pubDate>
    <dc:creator>GabrielaBuraglia</dc:creator>
    <dc:date>2025-03-10T03:30:51Z</dc:date>
    <item>
      <title>Help changing the icons in the LayerList Widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/help-changing-the-icons-in-the-layerlist-widget/m-p/1593711#M86652</link>
      <description>&lt;P&gt;I'm looking to add custom icons to the layerList widget. As you can see below, I achieved occasional success by following the documentation example here&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/widgets-layerlist-actions/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/sample-code/widgets-layerlist-actions/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GabrielaBuraglia_0-1741576965470.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/127468i126A911032F76666/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GabrielaBuraglia_0-1741576965470.png" alt="GabrielaBuraglia_0-1741576965470.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I use an async&amp;nbsp;&lt;SPAN&gt;listItemCreatedFunction, with an &lt;/SPAN&gt;&lt;SPAN&gt;await&lt;/SPAN&gt; &lt;SPAN&gt;item&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;layer&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;when&lt;/SPAN&gt;&lt;SPAN&gt;(); and then I c&lt;/SPAN&gt;&lt;SPAN&gt;reate a custom DOM element to hold the item.title with the custom icon. However, I can't make it work consistently. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any suggestions? Thanks in advance.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Mar 2025 03:30:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/help-changing-the-icons-in-the-layerlist-widget/m-p/1593711#M86652</guid>
      <dc:creator>GabrielaBuraglia</dc:creator>
      <dc:date>2025-03-10T03:30:51Z</dc:date>
    </item>
    <item>
      <title>Re: Help changing the icons in the LayerList Widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/help-changing-the-icons-in-the-layerlist-widget/m-p/1593819#M86656</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/886305"&gt;@GabrielaBuraglia&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I don't think this is really possible at this time.&amp;nbsp; The item's title property should only accept strings. I tried to use some UTF-8 encoded icons and didn't have any luck, I'm curious how you got it to work in the screenshot&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can set the list item's panel content to be any custom html content, but that's not going to show up like you want it on the title line.&amp;nbsp; Long term I think this could be a great enhancement and as we migrate the widgets to components adding a slot in front of the title for something like this should be possible.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Mar 2025 15:02:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/help-changing-the-icons-in-the-layerlist-widget/m-p/1593819#M86656</guid>
      <dc:creator>Sage_Wall</dc:creator>
      <dc:date>2025-03-10T15:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: Help changing the icons in the LayerList Widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/help-changing-the-icons-in-the-layerlist-widget/m-p/1593963#M86661</link>
      <description>&lt;P&gt;Ah I see, thank you for the info!! I am able to assign a custom DOM element to the item title property. I believe my issue is some sort of race condition, where sometimes it works in time (or in the correct order) to appear on the screen, and sometimes it doesn't. But I lack enough knowledge or understanding of the listItemCreatedFunction to time it correctly.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const layerList = new LayerList({ 
        view,
        container: document.createElement("div"),
        listItemCreatedFunction: customizeLayerList
      });
        // Function to add custom icons to each layer item
        async function customizeLayerList (event)
            {
              const item = event.item;
              await item.layer.when();

              const originalTitle = item.title;
              const iconSvg = layerIcons[originalTitle];
              
              // Custom DOM element, title with custom icon
              const customTitleContainer = document.createElement("div");
              customTitleContainer.style.display = "flex";
              customTitleContainer.style.alignItems = "center";
              customTitleContainer.style.width = "100%";
              
              const iconContainer = document.createElement("span");
              iconContainer.className = "custom-layer-icon";
              iconContainer.style.marginRight = "8px";
              iconContainer.style.display = "inline-flex";
              iconContainer.innerHTML = iconSvg;
              
              const textSpan = document.createElement("span");
              textSpan.textContent = originalTitle;
              textSpan.style.flex = "1";
              
              customTitleContainer.appendChild(iconContainer);
              customTitleContainer.appendChild(textSpan);
              
              // Set layer's title to custom DOM element
              item.title = customTitleContainer;
            }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Mar 2025 18:27:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/help-changing-the-icons-in-the-layerlist-widget/m-p/1593963#M86661</guid>
      <dc:creator>GabrielaBuraglia</dc:creator>
      <dc:date>2025-03-10T18:27:46Z</dc:date>
    </item>
  </channel>
</rss>

