@ashwinthomas/react-time-picker-dropdown

中文文档
1.1.0发布于 2026/09/26MITTypeScriptESM + CJS零依赖近 30 天下载 2254

A time picker for react webapp

原始使用文档
文档目录9 节
  1. Demo
  2. Getting Started
  3. Installation
  4. Usage
  5. TypeScript
  6. Upgrading from 1.0.x
  7. User guide
  8. TimePicker
  9. Props

React Time Picker Dropdown

A time picker component for your react app.

Demo

You can checkout the demo.

Getting Started

Installation

$ npm install --save @ashwinthomas/react-time-picker-dropdown

Usage

import TimePicker from '@ashwinthomas/react-time-picker-dropdown';

render() {
    <TimePicker
        defaultValue="10:10:00 am"
        useTwelveHourFormat={true}
        onTimeChange={handleTimeChange}        
    />
}

TypeScript

Type definitions are included. The props type is exported as TimePickerProps:

import TimePicker, { type TimePickerProps } from '@ashwinthomas/react-time-picker-dropdown';

const handleTimeChange: TimePickerProps['onTimeChange'] = (value) => {
    // value is a string like "10 : 10 : 00 am", or null
};

Upgrading from 1.0.x

1.1.0 keeps the same props, imports and output format. Notable changes:

  • The dropdown now commits and closes when you click outside the picker, the same as clicking the backdrop.
  • Unpadded times such as 9:5:0 are accepted, and values passed to onTimeChange always use the documented hh : mm : ss format (1.0.x could report extra spaces, e.g. "07 : 08 : 09 pm").
  • The OK button no longer submits a surrounding <form>.
  • Errors thrown inside onTimeChange or onInputChange are logged with console.error instead of being silently ignored.
  • The component is marked 'use client', so it can be imported directly from React Server Components (e.g. the Next.js App Router).

User guide

TimePicker

Displays an input field along with a dropdown to select time. The dropdown opens when the input is focused. It commits the selection and closes on Enter, Escape, the OK button, the clock icon, or a click outside the picker.

Values passed to onTimeChange and onInputChange are formatted as hh : mm : ss (or hh : mm : ss am in 12 hour format).

Props

Prop nameDescriptionDefault valueExample values
defaultValueSets default input value, supports formats hh:mm:ss a and hh:mm:ssnull"10:10:00 am"
placeholderCan be used to set input placeholder"00 : 00 : 00""hh : mm : ss"
useTwelveHourFormatUse useTwelveHourFormat props to switch between 24 / 12 hour formatfalsetrue
onTimeChangeFunction called when user picks a time. (Returns null if the input value is invalid.)n/a(value)=>alert("Time selected is: ", value)
onInputChangeFunction called when picker value changed using the dropdownn/a(value)=>alert("Display time changed: ", value)
showCloseIconshowCloseIcon can be used to toggle close icon visibilitytruetrue
showClockIconshowClockIcon can be used to toggle clock icon visibilitytruetrue
allowBackdropallowBackdrop can be used to toggle backdropfalsefalse

版本与发布记录

@ashwinthomas/react-time-picker-dropdown 共发布 7 个版本,首次发布于 2022/10/01;过去 12 个月发布了 1 个版本。

版本发布日期距今
1.1.0latest2026/09/261 个月前
1.0.52023/07/043 年前
1.0.42022/10/264 年前
1.0.32022/10/084 年前
1.0.22022/10/014 年前
1.0.12022/10/014 年前

关于 @ashwinthomas/react-time-picker-dropdown 的常见问题

@ashwinthomas/react-time-picker-dropdown 是什么?

A time picker for react webapp

如何安装 @ashwinthomas/react-time-picker-dropdown?

在项目目录运行 npm install @ashwinthomas/react-time-picker-dropdown,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^17.0.0 || ^18.0.0 || ^19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@ashwinthomas/react-time-picker-dropdown 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@ashwinthomas/react-time-picker-dropdown 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@ashwinthomas/react-time-picker-dropdown 可以商用吗?

@ashwinthomas/react-time-picker-dropdown 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@ashwinthomas/react-time-picker-dropdown 的下载量有多少?

根据 npm 官方下载统计,@ashwinthomas/react-time-picker-dropdown 在 2026/10/07 – 2026/11/05 这 30 天内被下载 2,254 次,日均约 75 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ashwinthomas/react-time-picker-dropdown 还在维护吗?

最新版本 1.1.0 发布于 2026/09/26(1 个月前);至今共发布 7 个版本,其中过去 12 个月发布了 1 个;首次发布于 2022/10/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。