Lottie files use static RGBA values and do not support currentColor. To change colors at runtime, use one of these two methods:
1. DOM manipulation (SVG renderer)
When using the svg renderer, listen for the DOMLoaded event and manually update the fill or stroke attributes of the rendered elements.
2. JSON pre-processing
Fetch the Lottie JSON, stringify it, and use replaceAll to swap the color array values (e.g., [0,0,0,1] for black) with your desired color before parsing it back to JSON and loading it via lottie-web.
// JSON pre-processing example
const response = await fetch('https://cdn.meteocons.com/latest/lottie/monochrome/rain.json');
const data = await response.json();
// Replace black [0,0,0,1] with a custom color
const json = JSON.stringify(data);
const colored = json.replaceAll(
'"c":{"a":0,"k":[0,0,0,1]}',
'"c":{"a":0,"k":[0.886,0.910,0.941,1]}' // #e2e8f0
);
lottie.loadAnimation({
container: el,
animationData: JSON.parse(colored),
renderer: 'svg',
loop: true,
autoplay: true
});