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

Manage pseudo class matching state for custom elements #813

Open
tkent-google opened this issue May 10, 2019 · 3 comments
Open

Manage pseudo class matching state for custom elements #813

tkent-google opened this issue May 10, 2019 · 3 comments

Comments

@tkent-google
Copy link
Contributor

Providing a way to make a custom element matchable to the following pseudo classes would be helpful.

:checked, :indeterminate, :in-range, :out-of-range, :required, :optional, :read-only, :read-write

Usecase:
A web author makes a checkbox-like custom element, and want to support :checked pseudo class like the built-in <input type=checkbox>.

We discuss a similar feature at #738. Its selector syntax is something like :state(checked), and it's not compatible with built-in elements.

Proposal and feedbacks:
The initial idea was #738 (comment) .
There is a concern about difficulty of correct usage; #738 (comment)

@enqueue
Copy link

enqueue commented Aug 26, 2022

While working with custom states via CustomStateSet and documenting their use is a viable option for component library authors, from a user's perspective it would be more intuitive to use the known standard CSS selectors.

There seems to be a rule in place for :disabled, which works. :invalid works, too, when setting the validity via ElementInternals. Unfortunately the selectors mentioned in this ticket, which are really related to input and other form associated elements, are currently not supported.

@justinfagnani
Copy link
Contributor

I've been building form elements recently and could really use the ability to act like a checkbox and use standard validation-related pseudo-classes.

What's needed to manage these with CustomStateSet? Do we need a separate set because this state isn't custom? Or can we just use the colon-prefixed names, like internals.states.add(":checked")?

@rniwa
Copy link
Collaborator

rniwa commented Oct 4, 2024

I don't think we want this to be a feature on CustomStateSet. If a checkbox is checked, we also need to convey that for AT as well. It makes more sense as an extension to ElementInternals since we already support matching :invalid, :out-of-range, etc... with ElementInternals.

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

5 participants