Skip to content

[Range] Add * to slider-thumb and tick - #1449

Merged
brechtDR merged 5 commits into
openui:mainfrom
brechtDR:range/improve-pseudo-element
Aug 27, 2026
Merged

[Range] Add * to slider-thumb and tick #1449
brechtDR merged 5 commits into
openui:mainfrom
brechtDR:range/improve-pseudo-element

Conversation

@brechtDR

Copy link
Copy Markdown
Collaborator

I following this idea for an API this would be logical.

…s api

# Conflicts:
#	site/src/pages/components/enhanced-range-input.explainer.mdx
@brechtDR
brechtDR force-pushed the range/improve-pseudo-element branch from d48340f to 23a68ad Compare May 21, 2026 11:51
@brechtDR brechtDR self-assigned this May 21, 2026

@lukewarlow lukewarlow left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should allow the non functional version to target all of them and the functional to target specific ones?

@lukewarlow

Copy link
Copy Markdown
Collaborator

There were discussions in the csswg about multiple slider-fills so it might be worth looking at those conversations?

@gregwhitworth

Copy link
Copy Markdown
Member

There were discussions in the csswg about multiple slider-fills so it might be worth looking at those conversations?

@lukewarlow mind linking to these conversations?

Comment thread site/src/pages/components/enhanced-range-input.explainer.mdx Outdated
@lukewarlow

Copy link
Copy Markdown
Collaborator

Sorry for the delay: w3c/csswg-drafts#12419

Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>

#### Exposing Thumb and Segment Geometry to CSS

To support layout customization beyond a straight horizontal track, we propose exposing each thumb's position along the track as a CSS custom property on the `::slider-thumb(*)` part (e.g. `--slider-thumb-position`, a percentage or `<number>` along the track), with segments similarly exposing their start and size. This is purely additional information for styling — it does not change hit-testing, keyboard behavior, or value computation, which remain based on the linear `min`/`max` model described above.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exposing custom properties by the browser is going to be a non-starter I suspect. I think instead a new function that returns the value is a better starting point. (Alternatively, perhaps we can get it from the CSS forms control-value() function or something)

Comment thread site/src/pages/components/enhanced-range-input.explainer.mdx
Comment thread site/src/pages/components/enhanced-range-input.explainer.mdx Outdated
Comment thread site/src/pages/components/enhanced-range-input.explainer.mdx Outdated
@brechtDR

brechtDR commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author

@lukewarlow I updated some of the explainer according to your feedback.

I think we should keep ::slider-thumb as well and just make it select the first thumb

Here I don't really agree; to be honest, it might be worth opening a discussion. I'd expect it to target all thumbs as well, which would make the (*) not needed anymore. For consistency's sake, the (*) would still be nice to have... It could even be used for differentiating a single range with a multi-range in a reset:

::slider-thumb { background: green; } /* single and multi-sliders are all green */
::slider-thumb(*) { background: orange;} /* now all single sliders are green, but the rangegroup ones are orange */
::slider-thumb(2) { background: red;} /* now all single sliders are green, but the rangegroup ones are orange, the second thumb is red */

Not taken up in this explainer, but something that came to mind is if these thumbs are actually considered siblings? This would allow you to do:

::slider-thumb(*) {
  --start-hue: 180; /* Teal */
  --hue-range: 120; /* Range from Teal to Magenta */
  
  /* distribute a range of hues across all items using sibling-count and index */
  background-color: oklch(
    65% 0.35
      calc(
        var(--start-hue) + (var(--hue-range) / (sibling-count() - 1)) *
          (sibling-index() - 1)
      )
  );
}

(pretty much this idea: https://codepen.io/utilitybend/pen/PwPxePK)

But that might be stretching it, and I'll make an issue of this later on. It should certainly be picked up, but maybe out of scope for this particular PR.

Tagging @gregwhitworth and @keithamus as well to inform. I was a bit delayed.

@lukewarlow
lukewarlow self-requested a review August 27, 2026 17:21

@lukewarlow lukewarlow left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think some of this probably needs further thought and maybe some details will be changed but approving to keep things moving.

@brechtDR

brechtDR commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

I think some of this probably needs further thought and maybe some details will be changed but approving to keep things moving.

@lukewarlow Absolutely. The way I see it, this is still getting the starting point up and running for the first experimental implementations.

@brechtDR
brechtDR merged commit 6716f39 into openui:main Aug 27, 2026
5 checks passed
@brechtDR
brechtDR deleted the range/improve-pseudo-element branch August 27, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants