Skip to content

CSS rgb and rgba functions can't accept custom property #257

Closed
@thomashigginbotham

Description

@thomashigginbotham

The following CSS results in the parser stripping the value.

:root {
  --my-color: 255, 0, 0;
}

body {
  color: rgb(var(--my-color));
}

It seems that the parser thinks the value is invalid since rgb expects three arguments and is only receiving one. However, the CSS works correctly in every major browser.

The reason I am using this syntax is because I'm passing the --my-color variable to various rgba functions throughout the style sheet, and while the color might change, the alpha value of each rgba function is defined separately. I.e., I can't set --my-color to rgba(255, 0, 0, .5) as I'd require hundreds of variables for each opacity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions