-
Notifications
You must be signed in to change notification settings - Fork 719
[css-selectors] Selectors for “text-ish” and “button-ish” inputs #2296
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
Comments
I realized I left out |
Also, |
I think your suggestions are a good start. Here's how I imagine them working:
|
I support this; I too have had to write these annoying exhaustive lists of selectors before (and they're potentially not even correct cross-platform - it's allowed for things to render differently between UAs, and in particular to switch between text-like and button-like on mobile vs desktop). |
I would also love something like this, I used EQCSS to make this a while ago:
And I left |
It’s also likely that Likewise, |
the The So...
Really? Please do not forget about ::dropdown-arrow. It looks like "button-ish". |
It’s not complete, though. You also need to exclude checkboxes, radio buttons, and, as you pointed out, color inputs. And possibly some others? I’m not sure. This is exactly the problem; it’s too complicated to do from memory.
Probably neither. These don’t necessarily need to be inclusive of all input types. |
My proposal for this problem and global usage will be published in next topic. I will link it here. |
It shows up like a |
Instead of adding gallizions of new pseudo-classes, also consider extending the syntax of attribute selectors, which can have benefits outside of HTML. For example: input[type in {text, search, tel, url, email, password,
date, month, week, time, number, color}] {}
input:not([type in {button, submit, reset}]) {} Still long, but looks much better. Basically, |
That is both super long and still super error prone. It could be nice to have attribute selectors like that but it isn't a valid solution to this issue. |
That's true for any input that has a type that isn't supported by the browser. The default type for I've seen the colour input get displayed as more of a button looking thing on phones. I think it should probably be excluded from the text-ish list. |
The color input is a perfect example of this. It appears often in desktop as a text field but appears more like a button on mobiles. Instead of specing it to say "these specific input types are By letting the browser decide what is a textbox and what is a button it makes the spec far less brittle. It also could allow for more control over form elements. I've often seen That would be more like styling pseudo elements though so maybe |
It is not argument. The I guess for it https://drafts.csswg.org/css-extensions/#custom-selectors
The |
That still works. If the browser shows Like @Dan503 said, let the browser decide what their mode of input type matches which criteria. |
If it's up to the browser to decide, that's about as good for me as no solution. I'd still be stuck writing my big long selector list just to be sure I know what's going to be styled with certainty. Where I also style Or here on another form: https://codepen.io/tomhodgins/pen/yOjrzx |
This is already implemented in a Reduced test case: https://jsfiddle.net/CyberAP/k7nr6d8y/ So the right selector would look like this: :read-write,
input:read-only,
textarea
{} To support Safari and Firefox change to this: :read-write
{}
:-moz-read-write
{}
input[readonly],
input[type=date],
input[type=time],
textarea
{} |
Given that we are already seeing some debate about what the appropriate groupings would be, I'm tempted to argue that the most practical approach would be to make it easier for authors to define custom selector lists. Yes, it still means you have to write out that long selector list at least once. But then it can be re-used many times in a project. And it can be re-used in many projects, by In #2298 (comment), I give a proposal for a syntax defined as an extension of |
Browser vendors already make lots of decisions. Even today, we have to neutralize left padding and margin on lists, and the world hasn’t ended. And vendors are now working together better than ever to bring their implementations in line with one another.
In these cases, we have a classic progressive enhancement scenario. The browsers ought to ignore the type it doesn’t support and default to |
and use of $textish or
and use :--textish and problem is resolved also for We really do not need gallizions of :pseudocalsses. We do not remember them after a time. I proposed $textish (with dollar sign) to mark the specificity of selector is the same like write these selectors. They can be preprocessed before interpretation of styles. |
The CSS Working Group just discussed
The full IRC log of that discussion |
Was the WICG project ever opened? |
|
Uh oh!
There was an error while loading. Please reload this page.
Spec: https://drafts.csswg.org/selectors/
In almost every project I do, I want to style all text-like inputs the same way. But targeting those, while not targeting button-like
s is tricky. I usually end up doing either of these solutions:
Both of these are more verbose than they should be, and they feel prone to breakage if/when new input types are added to HTML later on. I think there should be a pseudo-class to target all “text-ish” inputs.
Buttons are not quite as bad, but still tedious:
A pseudo-class shorthand for this would be useful as well.
And finally, a third pseudo-class to target checkboxes and radio buttons together (equivalent to
input[type="checkbox"], input[type="radio"]
).Possible names for these pseudo-classes could be
:text-input
,:button
, and:toggle
.The text was updated successfully, but these errors were encountered: