Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-variables-2][css-properties-values] Constants in CSS #10286

Open
Que-tin opened this issue May 7, 2024 · 2 comments
Open

[css-variables-2][css-properties-values] Constants in CSS #10286

Que-tin opened this issue May 7, 2024 · 2 comments

Comments

@Que-tin
Copy link

Que-tin commented May 7, 2024

Is there a reason that we don't constants in CSS yet?

I was looking trough the open issues and couldn't find a single one asking for it.

e.g. for stuff like font-families or theme independent colors like brand colors it would be great to have something like this to make sure they don't get overwritten.

The syntax could be similar to custom properties by replaying - with _ so __*. These should also be allowed in @property definitions.

I'm not 100% sure whether there should also be a new function to access these constants or whether the underscore are enough to differentiate the two when using var() for both. Open for discussion.

@Crissov
Copy link
Contributor

Crissov commented May 8, 2024

Try closed issues as well.

PS: #6099 for instance.

@andruud
Copy link
Member

andruud commented Jun 12, 2024

Closest I've seen is "custom env", #2627 (comment).

There are also a few proposals for registering a bunch of custom properties (and their initial values) in a less verbose way.

make sure they don't get overwritten

Does that mean you want the first rule that sets a constant to determine the value, and any further attempts to (re)set the value should be ignored? E.g.:

@env { --foo: 10px; }
@env { --foo: 20px; }
div {
  width: env(--foo); /* --10px */
}

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

No branches or pull requests

4 participants