Time selection
The date picker ships with five built-in variations for rendering the UI. The controls option supports the following:
date- renders a date-only scroller or dropdown controltime- renders a time-only scroller or dropdown controltimegrid- renders a time grid for time selectiondatetime- renders a date & time scroller or dropdowncalendar- renders a calendar view for date picking
When passing controls: ['time'], it will render a time-only picker - scroller for touchUi: true and a dropdown for touchUi: false. For a time grid use controls: ['timegrid'] instead.
You can change the timeFormat or rely on the formats coming from the locale settings.
Demo
<Datepicker
controls="['time ']"
touchUi=
/>
<Datepicker
controls="['time ']"
timeFormat="HH:mm"
touchUi=
/>
<Datepicker
controls="['time ']"
timeFormat="h:mm A"
touchUi=
/>
<Datepicker
controls="['time ']"
timeFormat="HH:mm:ss"
headerText="Time: {value}"
touchUi=
/>
import { Datepicker, Page, setOptions } from '@mobiscroll/react';
setOptions({
locale: ,
theme: ' ',
themeVariant: ' '
});
function App() {
return (
<Page>
<Datepicker controls={['time']} label="Time picker" labelStyle="stacked" inputStyle="outline" placeholder="Please Select..." />
<Datepicker
controls={['time']}
timeFormat="HH:mm"
label="24 hour picker"
labelStyle="stacked"
inputStyle="outline"
placeholder="Please Select..."
/>
<Datepicker
controls={['time']}
timeFormat="h:mm A"
label="12 h picker with AM/PM"
labelStyle="stacked"
inputStyle="outline"
placeholder="Please Select..."
/>
<Datepicker
controls={['time']}
timeFormat="HH:mm:ss"
headerText="Time: {value}"
label="Hour, Min, Sec"
labelStyle="stacked"
inputStyle="outline"
placeholder="Please Select..."
/>
</Page>
);
}
export default App;
import { Datepicker, Page, setOptions } from '@mobiscroll/react';
import { FC } from 'react';
setOptions({
locale: ,
theme: ' ',
themeVariant: ' '
});
const App: FC = () => (
<Page>
<Datepicker controls={['time']} label="Time picker" labelStyle="stacked" inputStyle="outline" placeholder="Please Select..." />
<Datepicker
controls={['time']}
timeFormat="HH:mm"
label="24 hour picker"
labelStyle="stacked"
inputStyle="outline"
placeholder="Please Select..."
/>
<Datepicker
controls={['time']}
timeFormat="h:mm A"
label="12 h picker with AM/PM"
labelStyle="stacked"
inputStyle="outline"
placeholder="Please Select..."
/>
<Datepicker
controls={['time']}
timeFormat="HH:mm:ss"
headerText="Time: {value}"
label="Hour, Min, Sec"
labelStyle="stacked"
inputStyle="outline"
placeholder="Please Select..."
/>
</Page>
);
export default App;