-
Notifications
You must be signed in to change notification settings - Fork 683
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
[css-selectors] Selectors for “text-ish” and “button-ish” inputs #2296
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<presenter> Topic: selectors for textish and buttonish elements<astearns> github: https://github.com//issues/2296 <presenter> fantasai: Use-case seems quite reasonable <presenter> fantasai: People wanna style things that look like buttons as a set <presenter> fantasai: But that set isn't clear, and it's a long list that changes over time, maybe across OSes, etc. <presenter> fantasai: So having a selector that classifies inputs as "buttonish" and "text inputish", so when you style buttonish you can style them all at once to look the same <presenter> fantasai: That seems reasonable to want. <bkardell_> aliases would help here, but also they wouldn't cover 'new' things that get/got added <presenter> TabAtkins: I've been in favor of this for a while. <presenter> emilio: textarea? <presenter> fantasai: Yes <presenter> AmeliaBR: Complex things - where text and button are both *parts* of it... <presenter> AmeliaBR: Pseudo-element to target pieces, maybe? <presenter> AmeliaBR: And other issue is which groupings makes sense. <presenter> AmeliaBR: I think there is consensus on textish and buttonish, and maybe popup-ish <presenter> fantasai: I think for popups UAs typically categorize those one way or the other <hober> q+ <presenter> TabAtkins: What's popup? <presenter> AmeliaBR: Like <input type=color>, raising a popup. <presenter> fantasai: The UA has to categorize, but for those with some options, UA should classify according to how they in particular do things. <presenter> fantasai: Compound things are complicated. <presenter> TabAtkins: I think for things like file input, when it's a text+button combo, it just matches neither. <astearns> ack hober <hober> hober: how does a custom element say it's buttonish or textish? <presenter> hober: How about custom elements that are buttonish? <presenter> TabAtkins: DOM is just now discussing API for custom elements to hook into forms, we should get into that convo. <presenter> bkardell_: Was Elika suggesting an ARIA role=button is buttonish? <presenter> fantasai: That's a possible way to handle the style mapping for custom things, yes. <presenter> fantasai: Unsure if it's a good idea, but it's a source of input. <tantek> q? <presenter> AmeliaBR: I would say don't do that. If the purpose is to target elements with a certain set of default browser styles, then the aria-role doesn't apply. <presenter> AmeliaBR: And it goes against the thing that ARIA is for custom widgets that don't fit into the browser default stylings. <astearns> +1 to role=button isn't buttonish for this discussion <tantek> q+ <presenter> bkardell_: Yeah, what's the intent is the question. <bdc> q+ <presenter> fantasai: One of the big things is getting styling that author doesn't know, because it's from the UA. For custom elements the author should know. <presenter> AmeliaBR: Another issue for this is verbosity, plus it's not forward compatible. If a new type gets added it could be buttonish, but it won't be in your selector today. <presenter> fantasai: And platform conventions can vary. <bkardell_> :ish() <xfq> ack tantek <presenter> tantek: I realize there's a point you can argue either way, but I think this is styling according ot the browser's default styling, not the semantics. <presenter> tantek: I think the instances AmeliaBR and elika pointed out are key here. <presenter> tantek: One input could be texty or buttony on different browsers, that's presentation, not semantic. <bkardell_> q+ <presenter> astearns: Does that suggest the name should be :browser-button, etc? <presenter> tantek: Not gonna bikeshed, just contributing to narrowing what we're solving <xfq> ack bdc <presenter> bdc: I find the intent pretty obscure to be honest. <presenter> bdc: The fact that we're avoiding a few selectors, or classes, isn't super compelling. <presenter> bdc: Forcing browsers to make the decision on whether it's buttonish or textish is weird. <presenter> [discussion on whether an input exists that could be ambiguous between the two categories] <xfq> ack bkardell_ <presenter> bkardell_: I think if you look around 2008ish in the archives, you'll find discussion about this sort of thing. <presenter> bkardell_: I think maybe Selectors, when it was still in CSS main, included some of these things? A button pseudo? <presenter> bkardell_: jQuery definitely supported these things, I think because it was in the spec at the time. <presenter> bkardell_: Every designer I know that tries to enforce this style runs into this problem. <presenter> bkardell_: We landed on the possibility of solving it with Tab's CSS Aliases thing. <AmeliaBR> jQuery `:button` selector: https://api.jquery.com/button-selector/ <presenter> bkardell_: Important to not create something that's bound too tightly to make tiny categories. <presenter> hober: I presented a form-submission API a few years ago, and the current proposal looks a lot like it. From what I recall it's not tied to the element being a custom element. <presenter> bkardell_: Yeah, just think it's important to consider the use-cases as holistically as possible, to make sure it gives authors a good experience. <presenter> astearns: So think I'm hearing *general* agreement on this, with some skepticism about whether it will end up being useful. <presenter> AmeliaBR: I don't usually say this, but this might be worth throwing it to WICG. <presenter> AmeliaBR: On that thread lots of people active in CSS communication/education, but not in standards. If we could convince Keith/etc to draft up some ideas, might be a useful way forward. <bkardell_> that seems good <presenter> TabAtkins: I support that. <presenter> fantasai: I think on the CSS side it's juts a few paragraphs. On the HTML side they'll have to define exactly how it applies. <presenter> TabAtkins: And there will be a DOM side, to opt your elements into things. <presenter> fantasai: If we don't have the extensibility, is it still worthwhile to have this in CSS? The CSS side is just like 15 minutes of work. <presenter> astearns: We'd still need the HTML side, right? <presenter> fantasai: That's more clarification, I'd think. <presenter> RESOLVED: Open up a new WICG project for this selector and it's sub-issues. |
Was the WICG project ever opened? |
|
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
<input>
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: