Skip to content

[colorManipulator] Alpha function not working with the hsl() notation #41729

@danilo-leal

Description

@danilo-leal

Steps to reproduce

StackBlitz repro: https://stackblitz.com/edit/react-ue9j7k-o6j3ve?file=Demo.js (inspect the Checkbox)

Current behavior

The theme file can receive colors in many formats, including hsl() and hsla(), and the System's alpha() function should be able to modify the alpha channel for all of them. That doesn't seem to be the case with hsl() at the moment. If my color shade is defined like this in the theme:

const blue = {
  main: 'hsl(210 20 10)',
};

And I use the alpha() function like so:

bgcolor: alpha(theme.palette.primary.main, 0.2)

I see this on the dev tools:

background-color: hsla(210, undefined%, undefined%, 0.2)

Expected behavior

I would expect the alpha() function to work the same as it does with HEX color values or even color(display-p3).

Context

I want to define all of the branding theme colors in HSL, a much easier to read/manipulate color notation, instead of HEX codes.

Search keywords: color manipulator, alpha function, hsl

Metadata

Metadata

Assignees

Labels

customization: cssDesign CSS customizability.scope: systemThe system, the design tokens / styling foundations used across components. eg. @mui/system with MUI

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions