Managing Themes
How to add, remove, and read themes in a .lottie package with dotlottie-io.
Managing Themes
Themes let a single .lottie package carry multiple visual variations (color palettes, property overrides) that a player can apply at runtime.
Adding a theme
dotlottie.addTheme("dark", "Dark Theme", JSON.stringify({ rules: [] }));id— a unique identifier for this theme within the packagename— an optional human-readable display name; passnullto omit itjsonData— the theme data as aBufferor JSON string, with a{ rules: [...] }shape
Associating a theme with an animation
Set a theme as an animation's default via initialTheme, or list several as available via themes, when calling addAnimation:
dotlottie.addAnimation("hero", heroBuffer, {
initialTheme: "dark",
themes: ["dark", "light"],
});Removing and reading themes
dotlottie.removeTheme("dark"); // throws if not found
dotlottie.getThemeJson("dark"); // → string | null
dotlottie.themeIds(); // → string[]Finding which animations use a theme
dotlottie.animationsUsingTheme("dark"); // → string[]See Querying Relationships for more cross-reference queries like this one.
Next up: Managing State Machines
Last updated: August 5, 2026 at 11:47 AMEdit this page