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

Allow registered custom properties to have a guaranteed-invalid initial value? #11676

Open
mirisuzanne opened this issue Feb 7, 2025 · 1 comment

Comments

@mirisuzanne
Copy link
Contributor

The guaranteed invalid value is useful when we want to provide inline fallbacks for a variable. But currently registered custom properties must have a valid initial-value. At that point, it's no longer possible to provide inline fallbacks – the variable will never again be guaranteed invalid, because it always has a value to revert to.

@mirisuzanne mirisuzanne added the css-variables-1 Current Work label Feb 7, 2025
@alexgagnon
Copy link

alexgagnon commented Feb 8, 2025

I'm starting to use @Property in a design system I'm working on and basically immediately ran into what I think is related to this issue. It's probably a me not understanding the spec more than anything but here's an example:

@property --spacing-override {
  syntax: "<length>";
  inherits: false;
  initial-value: ???;
}

@property --spacing {
  syntax: "<length>";
  inherits: true;
  initial-value: 20px;
}

button {
  padding: var(--spacing-override, var(--spacing));
}

When --spacing-override has anything other than a <length>, the property isn't registered at all, so it isn't set and the fallback is used. I appear to be able to give a custom-ident in syntax like "<length> | null", and then use "null" as the initial-value, which does register the property, but then --spacing-override is set and the fallback isn't used, even though the "null" value is invalid for padding.

A "guaranteed invalid" value seems like it would address this by saying: "register this property with a given syntax, but mark it as IACT unless it's explicitly set"?

I think this might have been suggested already here or might be loosely related to the "space toggle hack"?

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

3 participants