This sample demonstrates how to add a Legend component instance to a LayerList component. This is achieved by adding the legend
string to the panel of the appropriate ListItem in the LayerList component.
document.querySelector("arcgis-layer-list").listItemCreatedFunction = (event) => {
const { item } = event;
// Exclude group layers, otherwise the legend will be displayed twice
if (item.layer.type != "group") {
item.panel = {
content: "legend",
open: true
};
}
};