Re: [csswg-drafts] Allow registered custom properties to have a guaranteed-invalid initial value? (#11676)

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:

```css
@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](https://github.com/w3c/css-houdini-drafts/issues/1076#issuecomment-1272382719) or might be loosely related to the ["space toggle hack"](https://lea.verou.me/blog/2020/10/the-var-space-hack-to-toggle-multiple-values-with-one-custom-property/)?

-- 
GitHub Notification of comment by alexgagnon
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11676#issuecomment-2645743423 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Saturday, 8 February 2025 14:34:46 UTC