百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

react-time-picker

> 前端框架
开源

一个用于您的 React 应用程序的时间选择器。

385 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一个用于您的 React 应用程序的时间选择器。

React-Time-Picker

A time picker for your React app.

  • Supports virtually any language
  • No moment.js needed

tl;dr

  • Install by executing npm install react-time-picker or yarn add react-time-picker.
  • Import by adding import TimePicker from 'react-time-picker'.
  • Use by adding ``. Use onChange prop for getting new values.

Demo

A minimal demo page can be found in sample directory.

Online demo is also available!

Consider native alternative

If you don't need to support legacy browsers and don't need the advanced features this package provides, consider using native time input instead. It's more accessible, adds no extra weight to your bundle, and works better on mobile devices.

typescript

Looking for a date picker or a datetime picker?

React-Time-Picker will play nicely with React-Date-Picker and React-DateTime-Picker. Check them out!

Getting started

Compatibility

Your project needs to use React 16.3 or later. If you use an older version of React, please refer to the table below to find a suitable React-Time-Picker version.

React version Newest compatible React-Time-Picker version
≥16.8 latest
≥16.3 4.x
≥16.0 3.x

Installation

Add React-Time-Picker to your project by executing npm install react-time-picker or yarn add react-time-picker.

Usage

Here's an example of basic usage:

typescript
import { useState } from 'react';
import TimePicker from 'react-time-picker';

function MyApp() {
  const [value, onChange] = useState('10:00');

  return (
    

  );
}

Custom styling

If you want to use default React-Date-Picker and React-Clock styling to build upon it, you can import them by using:

typescript
import 'react-time-picker/dist/TimePicker.css';
import 'react-clock/dist/Clock.css';

User guide

TimePicker

Displays an input field complete with custom inputs, native input and a clock.

Props

Prop name Description Default value Example values
amPmAriaLabel aria-label for the AM/PM select input. n/a "Select AM/PM"
autoFocus Automatically focuses the input on mount. n/a true
className Class name(s) that will be added along with "react-time-picker" to the main React-Time-Picker `` element. n/a

String: "class1 class2"

Array of strings: ["class1", "class2 class3"]

                                                                                                                               |

| clearAriaLabel | aria-label for the clear button. | n/a | "Clear value" | | clearIcon | Content of the clear button. Setting the value explicitly to null will hide the icon. | (default icon) |

String: "Clear"

React element: ``

React function: ClearIcon

                                                                                                                    |

| clockAriaLabel | aria-label for the clock button. | n/a | "Toggle clock" | | clockProps | Props to pass to React-Clock component. | n/a | See React-Clock documentation | | clockIcon | Content of the clock button. Setting the value explicitly to null will hide the icon. | (default icon) |

String: "Clock"

React element: ``

React function: ClockIcon

                                                                                                                    |

| closeClock | Whether to close the clock on value selection. Note: It's recommended to use shouldCloseClock function instead. | true | false | | customInputsForm | form attribute for the custom hour, minute, second, and AM/PM inputs. Set to an empty string to exclude these inputs from their nearest ancestor form. | n/a | "my-form" | | data-testid | data-testid attribute for the main React-Time-Picker `` element. | n/a | "time-picker" | | disableClock | When set to true, will remove the clock and the button toggling its visibility. | false | true | | disabled | Whether the time picker should be disabled. | false | true | | format | Input format based on Unicode Technical Standard #35. Supported values are: H, HH, h, hh, m, mm, `s

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptreacttimetime-picker

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架