mui-x icon indicating copy to clipboard operation
mui-x copied to clipboard

[Time Picker] - How could I possibly customize the time picker?

Open vickonrails opened this issue 3 years ago • 3 comments

Duplicates

  • [X] I have searched the existing issues

Latest version

  • [X] I have tested the latest version

Summary 💡

First off, great job on the Library🙏.

Now to the point... The new TimePicker from mui-x doesn't meet my current visual needs and I'm looking to heavily customize it. Just wanted to find out if the community could point me in the right direction to do this.

Basically wanted to achieve something like this with a few criteria

  • 12 hour-time & 24 hour-time based on the personal settings
  • can enter the time manually
  • can select or scroll to select the time number

image

Something similar to this variant in the material design spec

image

Unfortunately, the closest implementation I can find in mui is this one

image

This misses a lot from the spec like

  • editing the time like a normal input field
  • scrolling/keyboard arrow keys to increment/decrement, etc

My questions are

  • Is it possible to customize it to the desired state in image 1?
  • If it is, what's the best way to go about this in your opinion?
  • If not, do you know of any time picker libraries that can fit this use case?

Thanks a lot in advance. Great job with the library!

Examples 🌈

No response

Motivation 🔦

No response

vickonrails avatar Jun 01 '22 11:06 vickonrails

I don't think it's possible because there's no way to replace the content rendered inside the popover. The one in the screenshot is completely different from the clock view we have. There're should be a way to replace CalendarOrClockPicker inside DesktopTimePicker to be able to achieve this layout.

About splitting the time input into two inputs, it's similar to https://github.com/mui/mui-x/issues/5021

Pinging @flaviendelangle and @alexfauquette since they work in this component.

m4theushw avatar Jun 01 '22 22:06 m4theushw

The UI you are proposing could be one of the variant we intend to implement in https://github.com/mui/mui-x/issues/4483

But we should also improve the ability to replace big parts of the UI for users wanting deep customization. We are currently introducing a slot system (like for the Data Grid) which is basically the foundations for this kind of override. For now, we start with small overrides, because once a component is overridable, its props becomes public API. And for now, a lot of the internal components don't have an API stable enough to do it. So it's a big piece of work that we are achieve bit by bit :+1:

flaviendelangle avatar Jun 02 '22 07:06 flaviendelangle

I have a similar requirement. I need to show time as a dropdown list (clients will be able to pick hours from a predefined list).

Ideally, I'd like to show two icons inside the input, one for date selection (with the current date picker), and the second for time (with list).

Searching over the net I found a similar component: https://ej2.syncfusion.com/react/demos/#/material/datetimepicker/default A similar thing can be done with and design TImePicker: https://codesandbox.io/s/hour-and-minute-antd-4-22-3-forked-s3y8ei?file=/demo.js But ideally, we should be able to specify a different style of picking time (hours in my case)

Misiu avatar Aug 04 '22 09:08 Misiu

@vickOnRails @Misiu We have added (https://github.com/mui/mui-x/pull/7176) the option to provide a custom view renderer to any of the picker views in v6. Could you double check if that would solve your use cases or is it still missing something?

LukasTy avatar Feb 08 '23 10:02 LukasTy

@LukasTy I missed that one, thx for the link. After a quick look at the provided demo we are able to override a view:

const timeViewRenderers = {
  hours: renderTimeViewClock,
  minutes: renderTimeViewClock,
  //seconds: renderTimeViewClock
};

but not sure if this will allow us to build a single view that will allow us to pick hours and minutes (like on screenshots in initial message). Idea is to unify hours and minutes view into a single view (with two inputs).

Misiu avatar Feb 08 '23 10:02 Misiu

but not sure if this will allow us to build a single view that will allow us to pick hours and minutes (like on screenshots in initial message). Idea is to unify hours and minutes view into a single view (with two inputs).

As you can see in the example linked within the issue as well as the fact, that all views have the same renderer—component. It should be possible, unless there would be some missing state/prop propagation, that would be needed to handle specific scenario.

LukasTy avatar Feb 08 '23 10:02 LukasTy

Is there a working example of a timepicker with a scrollable popover that lists hours and minutes? This is effectively the universal UI/UX for timepickers, including Google products (like GCal): Screen Shot 2023-04-17 at 2 02 39 PM

JStevens127 avatar Apr 17 '23 18:04 JStevens127

@JStevens127 We are currently working on providing the mentioned solution as the new default on desktop time pickers. 😉 You can check the new DigitalClock component here and the new default time picker view here.

LukasTy avatar Apr 18 '23 05:04 LukasTy

@LukasTy thats great news, thanks!

JStevens127 avatar Apr 18 '23 10:04 JStevens127

Closing this issue as the ability to provide your own view renderer has already been introduced in v6. For now, it's mentioned in the migration guide. We will improve upon it in the future with a dedicated page/section explaining it with more examples, but that is a separate issue on its own. 😃

LukasTy avatar May 01 '23 11:05 LukasTy