Skip to content

[system] blend() returns wrong colors for hsl() and color() inputs #49753

Done

Description

@PANJA-ABHISHEK

Steps to reproduce

This is a pure function, so it can be reproduced without a live example:

import { blend } from '@mui/system';

console.log(blend('#fff', 'hsl(0, 100%, 50%)', 0.5));
console.log(blend('#fff', 'color(srgb 1 0 0)', 0.5));
console.log(blend('#fff', 'rgb(255, 0, 0)', 0.5)); // same color as rgb, for comparison
  1. Run the code above.
  2. Compare the first two results with the third one.

Current behavior

The first call returns rgb(128, 178, 153) (a greenish grey) and the second returns rgb(128, 128, 128) (grey), while the rgb version returns rgb(255, 128, 128).

blend() takes the first three values of each decomposed color as rgb channels. For hsl() they are hue/saturation/lightness, and for color() they are in the 0-1 range, so the result is a wrong color with no warning.

Expected behavior

All three calls return rgb(255, 128, 128). Colors should be converted to rgb before blending, as getLuminance() already does for hsl colors.

Context

I was using blend() with theme colors defined in hsl. I have a fix with regression tests ready and will open a PR.

Your environment

npx @mui/envinfo
  System:
    OS: Windows 11 10.0.26200
  Binaries:
    Node: 26.13.0
    pnpm: 12.18.0
  Browsers:
    Chrome: 156.0.8078.80
  npmPackages:
    @mui/system: master (321fdae7e3)
    react: 19.3.1
    react-dom: 19.3.1

Not browser specific. Reproduced in Node and Chromium.

Search keywords: blend hsl color colorManipulator

Activity

  1. added
    status: waiting for maintainer
    on Nov 10, 2026
  2. added
    scope: system
    on Nov 17, 2026
  3. added
    type: bug
    and removed
    status: waiting for maintainer
    on Nov 24, 2026
  4. github-actions commented on Nov 24, 2026

    @github-actions
    Contributor

    This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
    Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.


    @PANJA-ABHISHEK Thanks again for creating this issue! If you have a moment, we would love to hear your thoughts on how we handled it with this short feedback form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: systemtype: bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions