-
Notifications
You must be signed in to change notification settings - Fork 680
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-forms] Allow making <button> a real inline (or block/flex/etc) #3226
Comments
I don't think you can explain all the For example, So it seems |
It indeed needs to act as a replaced element for some purposes by default. But we could disable the replaced element-ness if the inner box is not block-level, or some such. Basically like this, as author CSS to unstyle a button:
|
I don't like that the kind of box that is generated depends on the IMO a better way to approach this would be adding a new CSS property which can force an element to establish an independent formatting context (or behave like an inline-block if it's a non-replaced inline). Enable this on buttons via UA stylesheet, but let authors revert it to normal behavior. |
Good point, and good idea. If that property is used to turn off the independent formatting context, it would also turn off the element acting like a replaced element? And the inner box would inherit that property? |
I don't think I understand the reasoning for not just specifying |
I doubt that would be web compatible. |
What if the However, having the pseudo element that wraps all the content of the button could be useful for solving #2632 — it could get the default focus outline (similarly to that of the inline |
Well, I didn't think much about the differences between a normal inline-block and a replaced one, I'm not an expert in this. I don't think the property should allow to convert arbitrary elements to replaced, just create an independent formatting context, but maybe handle this case specially for buttons. Then yes, setting it to the initial value in buttons could make them normal inlines.
I don't really see how the inner box helps explaining the behavior of buttons. It can be useful for some unrelated purposes, but then I prefer my
I don't know but I have seen "CSS reset" stylesheets which use something like * { display: inline }
section, main, div /*...*/ { display: block } It's possible that they forgot |
Using both |
Here are rules and their counts in httparchive that set *-appearance: none and display: inline https://gist.github.com/zcorpan/4fea68aad8265cfa45d83f80586c9cf8 The sum of the nums is 2361. The data set is 1.3M pages. There could be multiple matches for a single page. Not all of these are buttons, and maybe some of these want to really unstyle their buttons. |
There could possibly be some buttons with |
To clarify, an explicit appearance: none would be needed, not just implicit by setting a border or a background color, right? |
I believe so. Honestly, in my opinion, what happens to the button when its default background is changed is "simplifying" its appearance rather than "undoing" it: the button loses the default OS-themed style, but (at least in Windows Chrome) it still has "pseudo 3d"-style border and it appears "pressed down" when activated. |
Yeah but appearance: none does the same (setting border or background implicitly sets appearance: none). |
See whatwg/html@c1e1f6f for a proposal for this. |
Thanks, I didn't realize this before! Then, it seems that the real meaning of |
Discussion on twitter here https://twitter.com/benoitrouleau/status/1088883974296997890?s=20 Made me think that maybe display: inline isn't a good hook for this. It's good if you want an inline, but what about if you want a without-magic block/grid/other? Maybe a new property is better, that is set by the UA stylesheet so that all: unset removes the magic. |
I’d much rather have |
@zcorpan Might I suggest changing the title of this issue to "Allow making a real inline/block/flex/whatever"? |
@benface, the @zcorpan, when I proposed |
@SelenIT Ah, I understand. I was more referring to the outer display though, e.g. make a |
I have another use case, but I'm not sure if it fits under the umbrella of this issue or whether it should be filed elsewhere? By default, the contents of a (If we want developers to use |
@OliverJAsh, interestingly, different browsers seem to have different bits of control over this "magic". Chrome/Mac changes the vertical position of the button contents if I add |
@SelenIT In Firefox, if you use |
That The magic defined in whatwg/html#4143 is more likely to match what we end up doing I think, but it's this issue is still an open issue, i.e. how to disable the magic. |
Maybe it would make sense to define the default vertical centering of the anonymous button content box in terms of |
I recently created a separate issue about the impossibility to make some elements, including I work on design systems / UI libraries, and in pretty much every library I've worked on, buttons are core components. And I always struggle with the same issue. I want my components to be flexible/responsive by default, meaning that when no explicit width is passed, I want them to adapt to their context: in block layout, they should stretch to fill their container's width (just like a Thank you for reading. ❤️ EDIT: I just made a proposal in #10282 that should fix the above, which I realize is just one part of this issue (doesn't solve the "real inline" part). |
Use cases & requests from web developers
https://twitter.com/ned/status/1051798190951940096
https://twitter.com/micahgodbolt/status/1047218367432544257
https://www.scottohara.me/blog/2018/10/03/unbutton-buttons.html
This post discusses the problem, and explores styling buttons with
display: contents
but notes that it loses the ability to receive keyboard focus and there's no accessibility node so it's not exposed as a button to screen readers.Defining layout model for buttons
In whatwg/html#4081 I'm working on specifying the layout model that buttons use. Currently my working draft for this is part of https://docs.google.com/document/d/1FE5YIoirPKxYbbnMd8kS6w39M8bzLTl5tf4wwOxR1wc/edit?usp=sharing
In particular, buttons have an inner anonymous box that is a block formatting context, and I think this is the cause of the inability to make buttons be inline.
Proposal
One way to solve this could be to add a pseudo-element to target the anonymous box, so that web developers can set it to 'display: inilne'. The button would still be focusable and be exposed the same in the accessibility tree.
Thoughts?
cc @tkent-google @MatsPalmgren @hober @FremyCompany
The text was updated successfully, but these errors were encountered: