<FormControl fullWidth>
<LocalizationProvider dateAdapter={AdapterDayjs}>
<TimePicker
views={["hours", "minutes", "seconds"]}
label={t("StrategyManager.Select_Time")}
value={timer}
onChange={(selectedTime) => handleTimeSelection(selectedTime, "timer")}
ampm={false}
/>
</LocalizationProvider>
</FormControl>
At the moment I have the above component in react and typescript using MUI version v6.16.1 but the popper only sits to the left of the parent field.
Ideally I'd like it to span the full width of the form control with equal width for each hours / minutes / seconds columns but I can't seem to target the wrapper.
Any help with styling this component would be really appreciated!
there is a way to do this, you have to use getBoundingClientRect()
to get the input width(with the help of useRef
). and then use it to set the time picker dropdown width, see my codesandbox example below
there are a few things you should note:
desktopModeMediaQuery=""
to deactivate the mobile variant of the time picker, because I'm overriding layout styles which breaks the mobile variantI honestly feel like this solution is very hacky so unless you really need it and didn't find a better alternative