React Time Picker

8.0.3 · active · verified Sun Apr 19

`react-time-picker` is a React component that provides an intuitive interface for users to select a specific time. It is actively maintained, with the current stable version being 8.0.3, released recently with improvements like OIDC trusted publishing and immutable releases. The library generally follows a stable release cadence, with major versions addressing significant breaking changes or new React features, and minor/patch versions focusing on bug fixes and enhancements. Key differentiators include its focus on accessibility, ease of integration into existing React projects, and reliance on native browser datetime capabilities where appropriate, while offering extensive customization for internationalization and display formats. It provides a clean, unopinionated UI that integrates well into various design systems, offering flexibility without enforcing a specific look and feel, and ships with TypeScript types for improved developer experience.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates basic usage of `TimePicker` component, including state management for the selected time, configuring display format, and importing necessary CSS for styling.

import React, { useState } from 'react';
import TimePicker from 'react-time-picker';
import 'react-time-picker/dist/TimePicker.css';
import 'react-clock/dist/Clock.css'; // Often needed for the clock overlay

type ValuePiece = Date | null;
type Value = ValuePiece | [ValuePiece, ValuePiece];

function MyTimePicker() {
  const [value, onChange] = useState<Value>(new Date());

  return (
    <div>
      <h1>Select a Time</h1>
      <TimePicker
        onChange={onChange}
        value={value}
        format="HH:mm" // Example format
        clearIcon={null} // Remove clear button if desired
        disableClock={true} // Disable the clock popover if only input is wanted
      />
      {value && <p>Selected time: {Array.isArray(value) ? value[0]?.toLocaleTimeString() : value.toLocaleTimeString()}</p>}
    </div>
  );
}

export default MyTimePicker;

view raw JSON →