---
title: "React date time scroller picker example | Mobiscroll"
component: "Date & Time"
framework: "React"
library_version: "6.2.0"
url: "https://demo.mobiscroll.com/react/datetime/date-time-picker"
---

# Date & time selection - React Date & Time demo

React Datetime scroller demo with date, hour and minute wheels. Featuring iPhone style rendering and format. With source code. For React and Next.js.

- [Live demo](https://demo.mobiscroll.com/react/datetime/date-time-picker)
- [View React JS code on GitHub](https://github.com/acidb/mobiscroll-demos-react/tree/main/src/demos/datepicker/datetime/date-time-picker)
- [View React TS code on GitHub](https://github.com/acidb/mobiscroll-demos-react-ts/tree/main/src/demos/datepicker/datetime/date-time-picker)
- This demo in other frameworks: [JavaScript](https://demo.mobiscroll.com/datetime/date-time-picker.md), [jQuery](https://demo.mobiscroll.com/jquery/datetime/date-time-picker.md), [Angular](https://demo.mobiscroll.com/angular/datetime/date-time-picker.md), [Vue](https://demo.mobiscroll.com/vue/datetime/date-time-picker.md)

## Description

The date picker ships with five built-in variations for rendering the UI. The [`controls` option](https://mobiscroll.com/docs/react/datepicker/api#opt-controls) supports the following:

- `date` - renders a date-only scroller or dropdown control
- `time` - renders a time-only scroller or dropdown control
- `timegrid` - renders a time grid for time selection
- `datetime` - renders a date & time scroller or dropdown
- `calendar` - renders a calendar view for date picking

Use `controls: ['datetime']` for rendering a date & time picker within the same control, tied to the same input, or use them separately for two inputs - `controls: ['date']` and `controls: ['time']`. It will render a scrollers for `touchUi: true` and a dropdowns for `touchUi: false`.

**Interested in dynamically switching between modes?** [Learn how to set up responsive behavior →](https://demo.mobiscroll.com/react/datetime/responsive)

## What this demo shows

- Three wheel-style configurations for selecting a single date and time.
- **Compact date and time picker** The first example uses separate scrollable wheels for the date, hour, minute, and AM/PM. The current date is labeled `Today`, while other dates use an abbreviated day, month, and date format.
- **Expanded date and time picker** The second example uses separate scrollable wheels for the month, date, and year, with the hour, minute, and AM/PM wheels displayed alongside them.
- **Date and time picker with separate inputs** The third example uses one input to open month, date, and year wheels and a second input to open hour, minute, and AM/PM wheels.
- **Input behavior** Each picker opens at the bottom of the container over a darkened backdrop. Clicking outside the picker closes it.
- **Scrolling behavior** The selected values appear in a central selection area, while neighboring values are visually subdued. Users scroll vertically through each wheel to change the selection.
- **Footer actions** In the input-based examples, `Cancel` discards the changes and `Set` confirms the selected values.
- **Input value** After the user selects `Set`, the input displays the confirmed value in the format configured for that example.

## Best for

- **Compact date and time selection** Forms and mobile interfaces where users need to choose a date and time in a space-efficient picker.
- **Detailed date and time selection** Workflows where displaying the month, date, year, and time wheels together makes each part of the selection easy to review.
- **Separate date and time fields** Forms that collect the date and time independently or apply separate validation and formatting to each value.

## Tutorial

```jsx
<Datepicker
    controls={['datetime']}
    touchUi={true}
/>
```

```jsx
<Datepicker
    controls={['date', 'time']}
    touchUi={true}
/>
```

```jsx
// date picker
<Datepicker
    controls={['date']}
    touchUi={true}
/>

// time picker
<Datepicker
    controls={['time']}
    touchUi={true}
/>
```

## API used in this demo

- [`theme`](https://mobiscroll.com/docs/react/datepicker/api#opt-theme) - option
- [`themeVariant`](https://mobiscroll.com/docs/react/datepicker/api#opt-themeVariant) - option
- [`controls`](https://mobiscroll.com/docs/react/datepicker/api#opt-controls) - option
- [`labelStyle`](https://mobiscroll.com/docs/react/datepicker/api#opt-labelStyle) - option
- [`inputStyle`](https://mobiscroll.com/docs/react/datepicker/api#opt-inputStyle) - option

## Code

### JSX

```jsx
import { Datepicker, Page, setOptions } from '@mobiscroll/react';

setOptions({
  theme: 'ios',
  themeVariant: 'light'
});

function App() {
  return (
    <Page>
      <Datepicker
        controls={['datetime']}
        label="Compact date & time picker"
        labelStyle="stacked"
        inputStyle="outline"
        placeholder="Please Select..."
      />
      <Datepicker
        controls={['date', 'time']}
        label="Expanded date & time picker"
        labelStyle="stacked"
        inputStyle="outline"
        placeholder="Please Select..."
      />
      <div className="mbsc-grid mbsc-no-padding">
        <div className="mbsc-row">
          <div className="mbsc-col-6">
            <Datepicker controls={['date']} label="Date" labelStyle="stacked" inputStyle="outline" placeholder="Please Select..." />
          </div>
          <div className="mbsc-col-6">
            <Datepicker controls={['time']} label="Time" labelStyle="stacked" inputStyle="outline" placeholder="Please Select..." />
          </div>
        </div>
      </div>
    </Page>
  );
}

export default App;
```

### TSX

```tsx
import { Datepicker, Page, setOptions } from '@mobiscroll/react';
import { FC } from 'react';

setOptions({
  theme: 'ios',
  themeVariant: 'light'
});

const App: FC = () => (
  <Page>
    <Datepicker
      controls={['datetime']}
      label="Compact date & time picker"
      labelStyle="stacked"
      inputStyle="outline"
      placeholder="Please Select..."
    />
    <Datepicker
      controls={['date', 'time']}
      label="Expanded date & time picker"
      labelStyle="stacked"
      inputStyle="outline"
      placeholder="Please Select..."
    />
    <div className="mbsc-grid mbsc-no-padding">
      <div className="mbsc-row">
        <div className="mbsc-col-6">
          <Datepicker controls={['date']} label="Date" labelStyle="stacked" inputStyle="outline" placeholder="Please Select..." />
        </div>
        <div className="mbsc-col-6">
          <Datepicker controls={['time']} label="Time" labelStyle="stacked" inputStyle="outline" placeholder="Please Select..." />
        </div>
      </div>
    </div>
  </Page>
);

export default App;
```

## Implementation notes

- Four independent `Datepicker` instances, each bound to its own input, illustrating three ways to combine date and time controls.
- **Compact picker** `controls: ['datetime']` renders a single combined wheel set (day/date label + hour + minute + AM/PM) in one control tied to one input.
- **Expanded picker** `controls: ['date', 'time']` renders the full month/date/year wheels alongside the hour/minute/AM-PM wheels in the same picker instance/input - two control types combined but still one input, distinct from the single fused `datetime` wheel of the compact variant.
- **Separate inputs** Two independent `Datepicker` instances are used instead of one: `controls: ['date']` on one input and `controls: ['time']` on the other, so date and time are captured, validated, and formatted independently.
- `touchUi` (true by default on touch devices) determines whether each picker renders as scroller wheels (`touchUi: true`) or dropdowns (`touchUi: false`); all three configurations respect it identically.

## Run it in your project

1. If not signed up yet, or don't own a license, you can [start a free trial](https://mobiscroll.com/starttrial).

2. Clone the repository:

   ```
   git clone https://github.com/acidb/mobiscroll-demos-react.git
   ```

3. If not installed yet, install the Mobiscroll CLI from NPM:

   ```
   npm install -g @mobiscroll/cli
   ```

4. Config Mobiscroll - open a terminal window in the root directory and run:

   ```
   mobiscroll config react
   ```

5. Install dependencies - open a terminal window in the root directory and run:

   ```
   npm install
   ```

6. Run the project:

   ```
   npm run dev
   ```

On a trial, add `--trial` to the config command: `mobiscroll config react --trial`.

Running a demo locally requires a Mobiscroll trial or a license; setup is per framework at https://mobiscroll.com/docs/react/getting-started/installation

## Related demos

- Previous: [Time selection](https://demo.mobiscroll.com/react/datetime/time-picker.md) - React Time picker demo with scroller wheel rendering for mobile and touch devices. Bottom or center display.
- Next: [Setting time select steps](https://demo.mobiscroll.com/react/datetime/time-value-steps.md) - React Date and time demo with 5 and 15 minute steps. Control hour, minute and second steps. With source code.
