How would I go about changing the styling for Individual entries in Leaflets layer control?

For example I would like to change the colour of "Layer 1" to red and the colour of "Layer 2" to blue.

Would this be done through the Javascript or the CSS?

enter image description here

1 Answer 1

L.control.layers({}, {
  "<span style='color:red'>Layer 1</span>": layer1,
  "<span style='color:blue'>Layer 2</span>": layer2,
  // etc
  • How would I do it in react-leaflet? <LayersControl.Overlay name="TEST" checked={true} ></LayersControl.Overlay>. For instance, make the font bold and red?
    – zakariah1
    Jul 11, 2023 at 19:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.