How can I help you?
Getting Started with React TimePicker component
10 Feb 202615 minutes to read
This section explains the steps required to create a simple React TimePicker component and demonstrate its basic usage in a React environment.
Ready to streamline your Syncfusion® React development? Discover the full potential of Syncfusion® React components with Syncfusion® AI Coding Assistant. Effortlessly integrate, configure, and enhance your projects with intelligent, context-aware code suggestions, streamlined setups, and real-time insights—all seamlessly integrated into your preferred AI-powered IDEs like VS Code, Cursor, Syncfusion® CodeStudio and more. Explore Syncfusion® AI Coding Assistant.
To get started quickly with React TimePicker, you can watch this video:
Setup for local development
Easily set up a React application using create-vite-app, which provides a faster development environment, smaller bundle sizes, and optimized builds compared to traditional tools like create-react-app. For detailed steps, refer to the Vite installation instructions. Vite sets up your environment using JavaScript and optimizes your application for production.
Note: To create a React application using
create-react-app, refer to this documentation for more details.
To create a new React application, run the following command.
npm create vite@latest my-appThis command will prompt you for a few settings for the new project, such as selecting a framework and a variant.

To set up a React application in TypeScript environment, run the following command.
npm create vite@latest my-app -- --template react-ts
cd my-app
npm run devTo set up a React application in JavaScript environment, run the following command.
npm create vite@latest my-app -- --template react
cd my-app
npm run devAdding Syncfusion® TimePicker packages
All the available Essential® JS 2 packages are published in the npmjs.com public registry.
To install the TimePicker component, use the following command
npm install @syncfusion/ej2-react-calendars --saveThe –save will instruct NPM to include the TimePicker package inside of the dependencies section of the package.json.
Adding CSS reference
The following CSS files are available in the ../node_modules/@syncfusion package folder. Add these as references in src/App.css.
@import "../node_modules/@syncfusion/ej2-base/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-lists/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-react-calendars/styles/tailwind3.css";To refer App.css in the application then import it in the src/App.tsx file.
Adding TimePicker component
The React TimePicker component can be added to the application by following these steps. To get started, add the TimePicker component to the src/App.tsx file using the following code.
The following timepicker code should be placed in the src/App.tsx file.
[Class-component]
import { enableRipple } from '@syncfusion/ej2-base';
import { TimePickerComponent } from '@syncfusion/ej2-react-calendars';
import * as React from "react";
import './App.css';
// enable ripple effect
enableRipple(true);
export default class App extends React.Component<{}, {}> {
public render() {
return <TimePickerComponent id="time" />
}
};[Functional-component]
import { enableRipple } from '@syncfusion/ej2-base';
import { TimePickerComponent } from '@syncfusion/ej2-react-calendars';
import * as React from "react";
import './App.css';
// enable ripple effect
enableRipple(true);
function App() {
return <TimePickerComponent id="time" />
};Run the application
Run the npm run dev command in the terminal to start the development server. This command compiles your code and serves the application locally, opening it in the browser.
npm run devThe output appears as follows.
[Class-component]
// import the ripple effect
import { enableRipple } from '@syncfusion/ej2-base';
// import the timepicker
import { TimePickerComponent } from '@syncfusion/ej2-react-calendars';
import * as React from "react";
import * as ReactDOM from "react-dom";
// enable ripple effect
enableRipple(true);
export default class App extends React.Component {
render() {
return <TimePickerComponent id="timepicker" placeholder="Select a Time"/>;
}
}
;
ReactDOM.render(<App />, document.getElementById('timer'));// import the ripple effect
import { enableRipple } from '@syncfusion/ej2-base';
// import the timepicker
import { TimePickerComponent } from '@syncfusion/ej2-react-calendars';
import * as React from "react";
import * as ReactDOM from "react-dom";
// enable ripple effect
enableRipple(true);
export default class App extends React.Component<{}, {}> {
public render() {
return <TimePickerComponent id="timepicker" placeholder="Select a Time" />
}
};
ReactDOM.render(<App />, document.getElementById('timer'));[Functional-component]
// import the ripple effect
import { enableRipple } from '@syncfusion/ej2-base';
// import the timepicker
import { TimePickerComponent } from '@syncfusion/ej2-react-calendars';
import * as React from "react";
import * as ReactDOM from "react-dom";
// enable ripple effect
enableRipple(true);
function App() {
return <TimePickerComponent id="timepicker" placeholder="Select a Time"/>;
}
;
ReactDOM.render(<App />, document.getElementById('timer'));// import the ripple effect
import { enableRipple } from '@syncfusion/ej2-base';
// import the timepicker
import { TimePickerComponent } from '@syncfusion/ej2-react-calendars';
import * as React from "react";
import * as ReactDOM from "react-dom";
// enable ripple effect
enableRipple(true);
function App() {
return <TimePickerComponent id="timepicker" placeholder="Select a Time" />
};
ReactDOM.render(<App />, document.getElementById('timer'));Now, the TimePicker renders with default culture as American English(‘en-US’). For a different culture, refer to the
Globalization section.
Setting the value, min, and max time
The following example demonstrates how to set the value, min and max time on initializing the TimePicker. Here the TimePicker allows you to select the time value within a range from 7:00 AM to 4:00 PM.
[Class-component]
// import the ripple effect
import { enableRipple } from '@syncfusion/ej2-base';
// import the timepicker
import { TimePickerComponent } from '@syncfusion/ej2-react-calendars';
import * as React from "react";
import * as ReactDOM from "react-dom";
// enable ripple effect
enableRipple(true);
export default class App extends React.Component {
// initialize the value, min and max time
time = (new Date('8/3/2017 10:00 AM'));
minTime = (new Date('8/3/2017 7:00 AM'));
maxTime = (new Date('8/3/2017 4:00 PM'));
render() {
return <TimePickerComponent id="timepicker" value={this.time} min={this.minTime} max={this.maxTime}/>;
}
}
;
ReactDOM.render(<App />, document.getElementById('timer'));// import the ripple effect
import { enableRipple } from '@syncfusion/ej2-base';
// import the timepicker
import { TimePickerComponent } from '@syncfusion/ej2-react-calendars';
import * as React from "react";
import * as ReactDOM from "react-dom";
// enable ripple effect
enableRipple(true);
export default class App extends React.Component<{}, {}> {
// initialize the value, min and max time
private time: Date = (new Date('8/3/2017 10:00 AM'));
private minTime: Date = (new Date('8/3/2017 7:00 AM'));
private maxTime: Date = (new Date('8/3/2017 4:00 PM'));
public render() {
return <TimePickerComponent id="timepicker" value={this.time} min={this.minTime} max={this.maxTime} />
}
};
ReactDOM.render(<App />, document.getElementById('timer'));[Functional-component]
// import the ripple effect
import { enableRipple } from '@syncfusion/ej2-base';
// import the timepicker
import { TimePickerComponent } from '@syncfusion/ej2-react-calendars';
import * as React from "react";
import * as ReactDOM from "react-dom";
// enable ripple effect
enableRipple(true);
function App() {
// initialize the value, min and max time
const time = (new Date('8/3/2017 10:00 AM'));
const minTime = (new Date('8/3/2017 7:00 AM'));
const maxTime = (new Date('8/3/2017 4:00 PM'));
return <TimePickerComponent id="timepicker" value={time} min={minTime} max={maxTime}/>;
}
;
ReactDOM.render(<App />, document.getElementById('timer'));// import the ripple effect
import { enableRipple } from '@syncfusion/ej2-base';
// import the timepicker
import { TimePickerComponent } from '@syncfusion/ej2-react-calendars';
import * as React from "react";
import * as ReactDOM from "react-dom";
// enable ripple effect
enableRipple(true);
function App() {
// initialize the value, min and max time
const time: Date = (new Date('8/3/2017 10:00 AM'));
const minTime: Date = (new Date('8/3/2017 7:00 AM'));
const maxTime: Date = (new Date('8/3/2017 4:00 PM'));
return <TimePickerComponent id="timepicker" value={time} min={minTime} max={maxTime} />
};
ReactDOM.render(<App />, document.getElementById('timer'));Setting the time format
Time formats is a way of representing the time value in different string format in textbox and popup list. By default, the TimePicker’s format is based on the culture. You can also customize the format by using the format property. To know more about the time format standards, refer to the Date and Time Format section.
The following example demonstrates the TimePicker component in 24 hours format with 60 minutes interval. The time interval is set to 60 minutes by using the step property.
[Class-component]
// import the ripple effect
import { enableRipple } from '@syncfusion/ej2-base';
// import the timepicker
import { TimePickerComponent } from '@syncfusion/ej2-react-calendars';
import * as React from "react";
import * as ReactDOM from "react-dom";
// enable ripple effect
enableRipple(true);
export default class App extends React.Component {
time = (new Date('8/3/2017 10:00'));
render() {
return <TimePickerComponent id="timepicker" value={this.time} step={60} format={'HH:mm'}/>;
}
}
;
ReactDOM.render(<App />, document.getElementById('timer'));// import the ripple effect
import { enableRipple } from '@syncfusion/ej2-base';
// import the timepicker
import { TimePickerComponent } from '@syncfusion/ej2-react-calendars';
import * as React from "react";
import * as ReactDOM from "react-dom";
// enable ripple effect
enableRipple(true);
export default class App extends React.Component<{}, {}> {
private time: Date = (new Date('8/3/2017 10:00'));
public render() {
return <TimePickerComponent id="timepicker" value={this.time} step={60} format={'HH:mm'} />
}
};
ReactDOM.render(<App />, document.getElementById('timer'));[Functional-component]
// import the ripple effect
import { enableRipple } from '@syncfusion/ej2-base';
// import the timepicker
import { TimePickerComponent } from '@syncfusion/ej2-react-calendars';
import * as React from "react";
import * as ReactDOM from "react-dom";
// enable ripple effect
enableRipple(true);
function App() {
const time = (new Date('8/3/2017 10:00'));
return <TimePickerComponent id="timepicker" value={time} step={60} format={'HH:mm'}/>;
}
;
ReactDOM.render(<App />, document.getElementById('timer'));// import the ripple effect
import { enableRipple } from '@syncfusion/ej2-base';
// import the timepicker
import { TimePickerComponent } from '@syncfusion/ej2-react-calendars';
import * as React from "react";
import * as ReactDOM from "react-dom";
// enable ripple effect
enableRipple(true);
function App(){
const time: Date = (new Date('8/3/2017 10:00'));
return <TimePickerComponent id="timepicker" value={time} step={60} format={'HH:mm'} />
};
ReactDOM.render(<App />, document.getElementById('timer'));Once the time format property is defined, it will be applicable to all the cultures.
Refer to the React TimePicker feature tour page for its groundbreaking feature representations. You can also explore our React TimePicker component example that shows how to render the TimePicker in React.