Skip to content

Conversation

@FBruzzesi
Copy link
Contributor

@FBruzzesi FBruzzesi commented Nov 21, 2025

📝 Summary

This is a proof of concept (maybe headstart?) to introduce a date_slider (edit: actually a date_range_slider) widget.

Fixes #6316

🔍 Description of Changes

  • Adds date_slider ui widget
  • Arguably too much refactor in the dates.py module
  • The frontend is 95% AI generated, that's why I am opening this as a draft, and happy to let anyone take it over. My main objective here was to see how feasible it was to add this component.
  • TODO: I would like to add the possibility to use a custom formatting that is applied to the dates before
Screenshot of rendering

image

📋 Checklist

  • I have read the contributor guidelines.
  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions. Thread link.
  • I have added tests for the changes made.
  • I have run the code and verified that it works as expected.

@vercel
Copy link

vercel bot commented Nov 21, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
marimo-docs Ready Ready Preview Comment Nov 21, 2025 10:30pm

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Nov 21, 2025
@FBruzzesi
Copy link
Contributor Author

FBruzzesi commented Nov 21, 2025

The automatic labeling to "documentation" seems off 🫠

@mscolnick
Copy link
Contributor

@akshayka @dmadisetti - curious if you think mo.ui.slider( should support date and datetime in the params, or if we should keep them separate under mo.ui.date_slider

@FBruzzesi
Copy link
Contributor Author

FBruzzesi commented Nov 21, 2025

@mscolnick for context this is a date range slider (I guess I could rename it), meaning start to end.
But in both cases, it would make sense to have those to be generic over a few types. In general I think also custom ordered sequences would be interesting (at least to me)

Screenshot:

image

@mscolnick
Copy link
Contributor

mscolnick commented Nov 21, 2025

I think if they are separate sliders, then it would be good rename to include range, but we can wait to see hear feedback if they should be merged.

(I'm leaning towards merging them if it's possible and the api does not get overloaded with different params when a int vs date)

@akshayka
Copy link
Contributor

akshayka commented Nov 21, 2025

Neat PR!

I am leaning toward adding two new APIs:

  1. date_slider
  2. date_range_slider

These are the reasons I prefer adding new APIs:

  1. The types are clear. mo.ui.slider(...).value is guaranteed to be numeric, so I can do arithmetic on it without having to check its type
  2. I can imagine feature creep related to dates (formatting, timezones) that might not relate to numeric sliders.

That said ... maybe the type concern could be addressed with generics and @overload, which would allow us to keep a single API (example). But that may be too complicated, and it would also be a breaking change because mo.ui.slider would become a function instead of a class.

(If we did use a single API, then I'd suggest we make the change across slider and range_slider at the same time, and also update steps to support date.)

@akshayka
Copy link
Contributor

akshayka commented Dec 5, 2025

In general I think also custom ordered sequences would be interesting (at least to me)

@FBruzzesi Can you describe your use case for custom ordered sequences? I am wondering if we just design for that solution instead of special casing dates

@FBruzzesi
Copy link
Contributor Author

FBruzzesi commented Dec 5, 2025

@FBruzzesi Can you describe your use case for custom ordered sequences? I am wondering if we just design for that solution instead of special casing dates

Hey @akshayka 👋🏼

First of all thanks for the patience in this PR, I am really tight these days. And thanks for considering a broader request.

Here a use case I have goes as follows.

I would like to create a range slider with a sequence that has a natural order. Specifically I would want to have a sequence of isoweeks. I build a library iso-week-date to simplify a bunch of operations in python (such as addition, subtraction and comparison), but in general notice that the iso weeks have a natural lexicographical order, e.g. "2025-W01" < "2025-W02").
With the library I can do: IsoWeek.range(start, end, step) and get a range of strings (or IsoWeek objects depending on another parameter).

If I were able to put these values into a slider, I can use such to filter a dataframe by some column (e.g. frame.filter(pl.col("week").is_between(pl.lit(slider.value[0]), pl.lit(slider.value[1]))) to either plot or report metrics in different time periods - this is my actual use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-change documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

slider option for date_range

3 participants