Open richiksc opened 4 years ago
@SebastianZ I meant stuff like this:
it would be a circular audio player with a draggable circle for controlling the duration of audio, so I need the runnable tracker
of input ['range'] type to be circular...
Wow, thank you @thebabydino for these detailed, wonderfully illustrated posts. This is amazing.
@MostafaFawzy7 Another example of a circular slider is often found in color pickers, for the hue:
However, I’m not sure this kind of styling is in scope for range input styling. I think this will probably still be best left to web components.
Standardizing the structure in OpenUI and the pseudo-elements in CSS (or a TF) seems like a good plan forwards. That said, I believe the original thinking behind calling this a "range" input and not just "slider" was that different UAs may want to use different UIs for selecting a number from a range. In practice this has not happened, and all have gone with a slider representation, but theoretically this is still possible. Whatever wording this standardisation effort uses should still allow for innovation in that space.
Logistics-wise, Open UI is currently structured as a CG, right? CGs cannot publish specs. It seems reasonable (and useful) to also have an Open UI WG. Is that something people are interested in?
I’m interested, if we think there are folks to help write and maintain said these works. I think OpenUI can help develop proposals for other working groups to review, @LeaVerou. Could you teach me how, as a WG, this might be different or better? I’ve always been a bit daft to how it all works.
Also... I was just referencing this post for the nth-time for our range/slider/progress/meter type components (because your research, @thebabydino, is so incredibly helpful), and I noticed your latest reply, Lea, is from just a few hours ago. That tells me, maybe this is still an active problem for folks. I’m be so happy to work together toward solutions that help us all.
@LeaVerou Thank you so much for this amazing answer, but let me ask about if this is available as an already based API for input range slider using the circular style?
Re: circular sliders (like the one below, which I coded a few years back)
My initial thought was they're not common. While searching for "slider design", I came across just two or three such results, the rest... all classic line sliders! So that seems to be an edge case, and if we take the same path as with selectmenu, a perfect use for having slots where we can replace the track with an SVG circle arc (and can even get a cool 3D look with SVG filters for that).
But then it was pointed out to me that they're rather common in some apps? So perhaps that's a blind spot for me? I don't have a smartphone, I don't use apps, I've relied solely on looking online for interesting designs in order to see what challenges they would pose when it comes to coding them.
So at this point... not sure.
My initial thought was they're not common. While searching for "slider design", I came across just two or three such results, … But then it was pointed out to me that they're rather common in some apps?
I think a circular "iPod style" input is easier to use with a touch input device, compared to a mouse or trackpad. That's probably why they're more common in apps than on websites.
One note about these pseudo-elements: as we're standardizing pseudo-elements like those proposed above (and implementing them), we need to be a little bit careful with their CSS cascading behavior relative to the user agent's styles on the hidden user-agent element that they affect. I think any user-agent styles inside the component should be treated either as an inner context or as from the user-agent origin, so that the pseudo-element overrides this. (I think the two options are distinguishable only in how they interact with other user-agent origin styles and with user styles.)
Historically Blink has treated the user agent's styles in this case as an inner context, with the exception of the style
attribute. I ran into this while working on <details>
element styling (for which I need to produce an updated proposal at some point soom), and I fixed it for unprefixed pseudo-elements (see background CL 1, backgroundCL 2, and mainly CL 3), but not for the existing prefixed ones, given that I didn't want to figure out the web compatibility implications (which appeared to affect a pretty large number of pseudo-elements, although maybe not the ones in this issue). In other words, the prior Blink behavior treated style attributes in the control (which are often used programatically rather than from markup) differently from style elements in the control. (It wouldn't surprise me if WebKit does the same, although I haven't checked.) I got feedback from the one developer (@bramus) who experimented with my details styling work that the resulting behavior was bad, and thus fixed it as I mentioned (see third CL above), so that style attributes and style elements are treated roughly the same (modulo their existing specified cascading differences).
I realize that we may or may not standardize what the structure and styles of the underlying elements are, but I think it's good if the interaction of any such pseudo-elements with the user agent's control at least behaves according to the CSS model, as though there are underlying elements with styles.
@thebabydino
My initial thought was they're not common. While searching for "slider design", I came across just two or three such results, the rest... all classic line sliders!
This may be a wording confound: I suspect these would not be called sliders by their UI designers, but something else. E.g. "knob" brings up a lot more results, and I'm not even sure it's the established term of art.
The CSS Working Group just discussed [css-pseudo-4] Standardizing input[type="range"] styling
, and agreed to the following:
RESOLVED: Add ::slider-thumb, ::slider-track
RESOLVED: Define these two pseudos as siblings of each other
RESOLVED: Apply them to <input type=range>, switch, <progress>, and <meter>
RESOLVED: Add ::slider-fill when relevant
RESOLVED: track, fill, thumb are in the same tree order as their usual painting order
ACTION hober: Add contributors in GH discussion to Acks
RESOLVED: acknowledge at least thebabydino
The CSS Working Group just discussed [css-pseudo-4] Standardizing input[type="range"] styling
.
Various element structures (not sure how much is web exposed)
Blink:
<progress>
<::-webkit-progress-inner-element>
<::-webkit-progress-bar>
<::-webkit-progress-value />
</>
</>
</progress>
<meter>
<::-webkit-meter-inner-element>
<::-webkit-meter-bar>
<::-webkit-meter-even-less-good-value />
or
<::-webkit-meter-suboptimum-value />
or
<::-webkit-meter-optimum-value />
</>
</>
</meter>
<input type="range">
<::-webkit-slider-container>
<::-webkit-slider-runnable-track>
<::-webkit-slider-thumb />
</>
</>
</input>
WebKit:
<progress>
<::-webkit-progress-inner-element>
<::-webkit-progress-bar>
<::-webkit-progress-value />
</>
</>
</progress>
<meter>
<::-webkit-meter-inner-element>
<::-webkit-meter-bar>
<::-webkit-meter-suboptimum-value />
</>
</>
</meter>
<input type="range">
<::-webkit-slider-container>
<::-webkit-slider-runnable-track>
<::-webkit-slider-thumb />
</>
</>
</input>
Firefox:
<progress>
<::-moz-progress-bar />
</progress>
:-moz-meter-sub-sub-optimum::-moz-meter-bar or :-moz-meter-sub-optimum::-moz-meter-bar or :-moz-meter-optimum::-moz-meter-bar
<meter>
<::-moz-meter-bar />
</progress>
<input type="range">
<::-moz-range-track />
<::-moz-range-progress />
<::-moz-range-thumb />
</input>
I can see it was resolved to apply these to input[type=range], meter and progress. I can I think work out the intention for range inputs
I interpret the below to be the new structure.
<input type="range">
<::slider-track />
<::slider-fill />
<::slider-thumb />
</input>
The intention for the others is less clear to me?
Would it simply translate to the below?
<meter>
<::slider-track />
<::slider-fill />
</meter>
<progress>
<::slider-track />
<::slider-fill />
</progress>
We didn't resolve on all-siblings vs. track as a parent of fill and a prev sibling of thumb. But other than that, yeah.
And don't forget the ::-webkit-resizer
in <textarea>
, which I had a proposal for many years ago.
https://lists.w3.org/Archives/Public/public-html-ig-zh/2013Jun/0029.html
On many pages, the range input also displays the current value, should we add a new pseudo-element for this?
IE used to have a ::-ms-tooltip
, which provides us with a reference, so standardizing ::tooltip
(csswg#8930 ) in CSS would be the way forward. @LeaVerou
See also: https://css-tricks.com/sliding-nightmare-understanding-range-input/#aa-tooltip-current-value-display
There is an angle picker in Chrome DevTools, which requires some ticks, pointers for style, and shortcuts like Shift + click
for interaction.
There is an angle picker in Chrome DevTools, which requires some ticks, pointers for style, and shortcuts like Shift + click for interaction.
I think this type of UI would require more than just CSS pseudo elements, you'd need to somehow make dragging work. All browser engines currently assume dragging is always in a single axis.
I think this type of UI would require more than just CSS pseudo elements, you'd need to somehow make dragging work. All browser engines currently assume dragging is always in a single axis.
Yes, I also think it's too complicated to add it to the range input, maybe this needs a new HTML element for that.
@lukewarlow The range input in Edge will have more pseudo-elements that you can update to your reply.
::-ms-fill-lower
::-ms-fill-upper
::-ms-ticks-before
::-ms-ticks-after
::-ms-thumb
::-ms-track
::ms-tooltip
And don't forget the
::-webkit-resizer
in<textarea>
, which I had a proposal for many years ago.
That’s not as simple, because I believe the triangular resizing UI is not part of the spec, so you'd want to allow different UIs like horizontal or vertical dividers.
Though then again, no harm in having a pseudo for the triangular resizer which simply doesn't exist in these cases.
Consideration also needs to be given to introducing a new property to control the direction of the progress bar. https://github.com/whatwg/html/issues/4177
And don't forget the
::-webkit-resizer
in<textarea>
, which I had a proposal for many years ago.That’s not as simple, because I believe the triangular resizing UI is not part of the spec, so you'd want to allow different UIs like horizontal or vertical dividers.
Though then again, no harm in having a pseudo for the triangular resizer which simply doesn't exist in these cases.
Yes, I admit that the ::resizer
issue is a bit more complicated and this should be opened as a separate issue.
Consideration also needs to be given to introducing a new property to control the direction of the progress bar. whatwg/html#4177
This can just be direction
… see https://github.com/whatwg/html/issues/8413#issuecomment-1326009453
Consideration also needs to be given to introducing a new property to control the direction of the progress bar. whatwg/html#4177
This can just be
direction
… see whatwg/html#8413 (comment)
@mfreed7 Only direction
cannot be made to display vertically. See: https://github.com/whatwg/html/issues/4177#issuecomment-1882909538
I think the idea of separately controlling orientation of a control from writing-mode/direction has merit, but it needs its own issue. It's more widely applicable than <input type=range>
after all. It would make controls even more complex as then you will need to account for writing-mode being X, but orientation being Y, but it might not be insurmountable now the code to account for writing-mode has been added.
Controlling the orientation of the slider through writing-mode
is a hack, as writing-mode
is intended for linguistic control, and that's in many cases a presentational decision in UIs with non-vertical writing modes.
In addition, we need to clarify whether these pseudo-elements should support the content
property. See https://github.com/openui/open-ui/issues/959#issuecomment-1866027222
I think the idea of separately controlling orientation of a control from writing-mode/direction has merit, but it needs its own issue. It's more widely applicable than
<input type=range>
after all. It would make controls even more complex as then you will need to account for writing-mode being X, but orientation being Y, but it might not be insurmountable now the code to account for writing-mode has been added.
Given the comments, I've filed https://github.com/w3c/csswg-drafts/issues/9832 to discuss the orientation/direction question.
Has there been any further discussion on the anatomy of a range input given these new ::track and ::thumb (assuming https://github.com/w3c/csswg-drafts/issues/9830) and ::fill (::slider-fill?) pseudos?
As far as I understand there's still the issue that WebKit (and blink) differ from Gecko's arrangment of the track, thumb, and fill?
We've been able to implement every component so far in our new CSS based design system using CSS only. Range styling was the first major roadblock where we couldn't accomplish an accessible design across browsers without resorting to JavaScript.
This looks like a great and simple proposal to me, getting it standardised and implemented would allow the removal of a lot of poor workarounds across the web.
<input type="range">
<::slider-track />
<::slider-fill />
<::slider-thumb />
</input>
Currently, the state of styling
<input type="range">
across browsers is a nightmare. Chrome, IE, Safari, and Edge each have their own way of styling range inputs with differently named pseudo-elements. With this proposal, I want to bring some unity and standardization to this similar to the CSS scrollbars spec. Currently, Chrome has no support for styling the "progress" part of a range input (the area corresponding to "below" the current value, in LTR languages, the track to the left. @danielstern has written an article about it on CSS-Tricks, and although it was last updated in 2017, most of it still applies.Definitions
Thumb: the UI element that the user interacts with and is dragged by the user - it shows the current state of the range. Track: The "groove" or bar that the thumb runs along - shows the "range" (min and max values) of the range.
Current state of range styling
WebKit/Blink (Chrome/Opera/Safari):
Firefox
IE/Edge
Proposal
As you can see, attempting to style a consistent range input across browsers is a daunting task and requires a lot of CSS and repetition of styles. I'd like to propose three new standard pseudo-elements for styling the range:
Sample CSS for the above mockup would be something like this: