Skip to content
Related Articles

Related Articles

Improve Article

ReactJS Blueprint TimePicker Component

  • Last Updated : 09 Jul, 2021

BlueprintJS is a React-based UI toolkit for the web. This library is very optimized and popular for building interfaces that are complex data-dense for desktop applications. TimePicker Component allows the user to specify a time. We can use the following approach in ReactJS to use the ReactJS Blueprint TimePicker Component.

TimePicker Props:

  • autoFocus: It is used to indicate whether to focus the first input when it opens initially.
  • className: It is used to denote a space-delimited list of class names to pass along to a child element.
  • defaultValue: It is used to denote the initial time the TimePicker will display.
  • disabled: It is used to indicate whether the time picker is non-interactive.
  • maxTime: It is used to denote the latest time the user can select.
  • minTime: It is used to denote the earliest time the user can select.
  • onBlur: It is a callback function that is triggered on blur event emitted by specific time unit input
  • onChange: It is a callback function that is triggered when the user changes the time.
  • onFocus: It is a callback function that is triggered on a focus event emitted by a specific time unit input.
  • onKeyDown: It is a callback function that is triggered on keydown event emitted by specific time unit input.
  • onKeyUp: It is a callback function that is triggered on keyup event emitted by specific time unit input.
  • precision: It is used to denote the precision of time the user can set.
  • selectAllOnFocus: It is used to indicate whether all the text in each input should be selected on focus.
  • showArrowButtons: It is used to indicate whether to show arrows buttons for changing the time.
  • useAmPm: It is used to indicate whether to use a 12-hour format with an AM/PM dropdown.
  • value: It is used to denote the currently set time.

Creating React Application And Installing Module:

  • Step 1: Create a React application using the following command:

    npx create-react-app foldername

     



  • Step 2: After creating your project folder i.e. foldername, move to it using the following command:

    cd foldername
  • Step 3: After creating the ReactJS application, Install the required module using the following command:

    npm install @blueprintjs/core
    npm install @blueprintjs/popover2

Project Structure: It will look like the following.

Project Structure

Example: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.

App.js




import React from 'react'
import { TimePicker } from '@blueprintjs/datetime'
  
function App() {
  
    return (
        <div style={{
            display: 'block', width: 400, padding: 30
        }}>
            <h4>ReactJS Blueprint TimePicker Component</h4>
            <TimePicker />
        </div >
    );
}
  
export default App;

Step to Run Application: Run the application using the following command from the root directory of the project:

npm start

Output: Now open your browser and go to http://localhost:3000/, you will see the following output:

Reference: https://blueprintjs.com/docs/#datetime/timepicker

My Personal Notes arrow_drop_up
Recommended Articles
Page :