mantinedev / mantine

A fully featured React components library
https://mantine.dev
MIT License
26.87k stars 1.9k forks source link

Datepicker should have month/year selection #332

Closed tracker1 closed 3 years ago

tracker1 commented 3 years ago

Datepicker title click should switch to a month picker, then the month picker a year spinner/picker. The pattern was first really codified in the MS Ajax Toolkit, probably the only thing I liked in that framework.

The issue is that someone will use this library, and then use it for something like a date of birth field.

rtivital commented 3 years ago

Hi Michael, I understand your point, but this is not a common pattern. You can add year and month picking to DatePicker with withSelect prop – https://mantine.dev/dates/date-picker/#year-and-month-picker We've chosen this pattern because most of the users are familiar with it and in most cases it will take less effort to switch into the desired year and month.

tracker1 commented 3 years ago

@rtivital thanks for pointing that out... I really didn't go that far down... When reviewing new UI components, the date of birth use case, how resizing the view (mobile vs desktop), and how modals and the background scrolling are handled (suppressed or not) are the main things I look at. They're just common issues that I tend to find in new frameworks when I come across them.

The pattern mentioned is relatively popular, and is part of the Fluent UI pattern for Calendar pickers. I also like the Cupertino (Apple) picker as well. Not as fond of the Material UI picker, though it's my favorite UI outside that.

Far from perfect, but I did make one myself a few years ago here. The demo is in multi-month display mode, and will shrink when the screen is too small to fit the 3 months. I don't even recall what it was originally for. I now tend to just use type="date" on the input components deferring to the browser/system selector.

tracker1 commented 3 years ago

https://github.com/tracker1/md-datepicker

rtivital commented 3 years ago

Thanks for feedback, we will be implementing something similar in future versions, it looks better than current implementation with two selects.

gregorybellencontre commented 2 years ago

Hello @rtivital I don't find any option to turn the date picker into a month picker. You were talking about the withSelect prop, but it seems it doesn't exist anymore. I checked the releases notes, but I didn't find any information about it.

rtivital commented 2 years ago

No DatePicker cannot be converted to MonthPicker

gregorybellencontre commented 2 years ago

Ok. And there's no other solution for month picking in Mantine ?

rtivital commented 2 years ago

No

elarens commented 2 years ago

Vitaly, is there any plan to add monthly picker functionality in foreseeable future? It's quite useful

geoffreyhale commented 2 years ago

Our team would love a MonthPicker

rtivital commented 2 years ago

I will not have the capacity to work on this any time soon

Nzent commented 2 years ago

Also, add a year picker too if you have time 👍

UsamaEjaz0 commented 1 year ago

Please add month picker and year picker

barissayil commented 1 year ago

Hi @rtivital I think adding MonthPicker and YearPicker which are slightly modified versions of DatePicker would be perfect. Do you think we could have this in the next few months, or if not at a later time?

rtivital commented 1 year ago

https://v6.mantine.dev/changelog/6-0-0/#updated-mantinedates-package

Jshihs commented 1 year ago

Hi rtivital, how can i use mantinedates package (month range picker, single month allowed) in dash plotly (python)?

rtivital commented 1 year ago

If it supports react, then yes

Jshihs commented 1 year ago

hi rtivital, thanks for quick reply. I am quite a newbie that I am not sure that i understand how to make it work in my coding. Here below is a brief coding and that will shows dates in selection. Kindly advise how to have only month shown as Mantine MonthPicker work in my python coding. thank you

import dash_bootstrap_components as dbc import dash_mantine_components as dmc from datetime import date, datetime

layout = dbc.Row([ dbc.Col([ dmc.DatePicker( id='start_date', label='Start date:', value=datetime.now().date().replace(month=1,day=1), ), ], width={'size':4,}),
dbc.Col([ dmc.DatePicker( id='end_date', label='End date:', value=datetime.now().date().replace(month=12,day=31), ), ], width={'size':4,}), ])

rtivital commented 1 year ago

You should ask this question in dash-mantine repo, I do no have any experience with Python