Skip to content

fix: support CSS color names in SVG fill and other properties (#1114)#1149

Open
Nikunjvadher wants to merge 1 commit into
juliangarnier:masterfrom
Nikunjvadher:fix/svg-fill-color-names
Open

fix: support CSS color names in SVG fill and other properties (#1114)#1149
Nikunjvadher wants to merge 1 commit into
juliangarnier:masterfrom
Nikunjvadher:fix/svg-fill-color-names

Conversation

@Nikunjvadher

@Nikunjvadher Nikunjvadher commented Feb 27, 2026

Copy link
Copy Markdown

Summary

Fixes #1114 by adding comprehensive support for CSS color names (e.g., "red", "blue", "transparent") in animations.

Context

In Anime.js v4, using a color name as an animation value caused a silent failure because the engine did not recognize these strings as valid colors. This prevented them from being interpolated with other color formats like RGBA or Hex.

Changes

  • New Mapping: Added src/core/color-names.js with 140+ CSS-standard color-to-RGBA mappings.
  • Improved Parsing: Updated isCol and convertColorStringValuesToRgbaArray to recognize and parse these names.
  • Verified Fix:

Fixes #1114

- Added a comprehensive mapping of 140+ CSS color names to RGBA values in src/core/color-names.js.
- Updated isCol helper to recognize standard color names.
- Enhanced convertColorStringValuesToRgbaArray to parse color names into RGBA arrays.
- Added specialized automated tests in tests/suites/color-names.test.js.
- Updated distribution bundles in dist/ with the new logic.

This fixes an issue where SVG animations using color names (like 'red')
were ignored when interpolating with other color formats.
@Nikunjvadher Nikunjvadher changed the title fix: add support for CSS color names in SVG fill and color properties fix: support CSS color names in SVG fill and other properties (#1114) Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] SVG fill ignored for colour names

1 participant