lightningcss icon indicating copy to clipboard operation
lightningcss copied to clipboard

Support `:state(<custom-ident>)` and other pseudo-classes

Open skanne opened this issue 4 months ago • 5 comments

Please officially support the pseudo-class :state(<custom-ident>)! It is marked as Baseline 2024 and is supported by all major browsers. See https://developer.mozilla.org/en-US/docs/Web/CSS/:state

Currently, lightningcss spits out the following warning:

'state' is not recognized as a valid pseudo-class. Did you mean '::state' (pseudo-element) or is this a typo?

skanne avatar Aug 09 '25 14:08 skanne

This is also blocking us in our Next.js project from adopting Turbopack because it relies on Lightning CSS.

georgwittberger avatar Aug 15 '25 11:08 georgwittberger

+1

Here's an example of valid selector with CSS custom state using Web Awesome library.

 wa-checkbox:active:not(:state(disabled))::part(control) {
    border-color: purple;
 }

zedix avatar Aug 27 '25 16:08 zedix

I'll give it a try?

jp-knj avatar Oct 20 '25 13:10 jp-knj

Update: Initially I asked for support of :state(<custom-ident>) only, but there are a number of other pseudo-classes and -elements that are already (or very close to being) baseline, but not recognized by lightningcss.

Example: ::highlight()

skanne avatar Nov 20 '25 12:11 skanne

If any Lightning CSS maintainer sees this: please consider accepting sponsors.

benface avatar Nov 20 '25 13:11 benface