Skip to content

[colorManipulator] Replace colorManipulator with CSS Relative Color Syntax (RCS) #43180

@oliviertassinari

Description

@oliviertassinari

Summary

The codebase rely on logic like

export function alpha(color, value) {

which comes with bundle size. However, CSS Relative Color Syntax (RCS) https://lea.verou.me/specs/#relative-colors-rcs is coming. We will be able to rely on it. This should save bundle size and improve the customization experience as it will be clearer in the Browser devtool inspector tool where the color is coming from.

Examples

--color-lighterer: oklch(from var(--color) calc(l + 0.2) c h);
--color-alpha-50: oklab(from var(--color) l a b / 50%);

On the colorspace we want to use, oklch looks like a solid option: https://www.smashingmagazine.com/2023/08/oklch-color-spaces-gamuts-css/. It has a limit though: w3c/csswg-drafts#9449, to be careful.

To see how this fit with color-mix(.


If this is successful, we could also look doing the same for the color contrast utils. Actually, we might even need to consider both problems at the same time. https://lea.verou.me/blog/2024/contrast-color/ is a great dive into the topic. A must read (e.g. APAC vs. legal requirement).

Motivation

Is likely part of solving #40104, and #37901.

Search keywords: -

Metadata

Metadata

Assignees

Labels

customization: cssDesign CSS customizability.performancescope: systemThe system, the design tokens / styling foundations used across components. eg. @mui/system with MUItype: enhancementIt’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions