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

react-datetimerange-picker

> 前端框架
开源

一个用于 React 应用程序的日期时间范围选择器。

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

工具介绍

一个用于 React 应用程序的日期时间范围选择器。

React-DateTimeRange-Picker

A datetime range picker for your React app.

  • Pick days, months, years, or even decades
  • Supports virtually any language
  • No moment.js needed

tl;dr

  • Install by executing npm install @wojtekmaj/react-datetimerange-picker or yarn add @wojtekmaj/react-datetimerange-picker.
  • Import by adding import DateTimeRangePicker from '@wojtekmaj/react-datetimerange-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 datetime input instead. It's more accessible, adds no extra weight to your bundle, and works better on mobile devices.

typescript

Looking for a time picker or a datetime picker?

React-DateTimeRange-Picker will play nicely with React-Date-Picker, React-Time-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-DateTimeRange-Picker version.

React version Newest compatible React-DateTimeRange-Picker version
≥16.8 latest
≥16.3 4.x
≥16.0 2.x

React-Calendar, on which React-DateTimeRange-Picker relies heavily, uses modern web technologies. That's why it's so fast, lightweight and easy to style. This, however, comes at a cost of supporting only modern browsers.

Installation

Add React-DateTimeRange-Picker to your project by executing npm install @wojtekmaj/react-datetimerange-picker or yarn add @wojtekmaj/react-datetimerange-picker.

Usage

Here's an example of basic usage:

typescript
import { useState } from 'react';
import DateTimeRangePicker from '@wojtekmaj/react-datetimerange-picker';

type ValuePiece = Date | null;

type Value = ValuePiece | [ValuePiece, ValuePiece];

function MyApp() {
  const [value, onChange] = useState([new Date(), new Date()]);

  return (
    

  );
}

Custom styling

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

typescript
import '@wojtekmaj/react-datetimerange-picker/dist/DateTimeRangePicker.css';
import 'react-calendar/dist/Calendar.css';
import 'react-clock/dist/Clock.css';

User guide

DateTimeRangePicker

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

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
calendarAriaLabel aria-label for the calendar button. n/a "Toggle calendar"
calendarProps Props to pass to React-Calendar component. n/a See React-Calendar documentation
calendarIcon Content of the calendar button. Setting the value explicitly to null will hide the icon. (default icon)

String: "Calendar"

React element: ``

React function: CalendarIcon

                                                                                                                                            |

| className | Class name(s) that will be added along with "react-datetimerange-picker" to the main React-DateTimeRange-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

                                                                                                                                                     |

| clockProps | Props to pass to React-Clock component. | n/a | See React-Clock documentation | | closeWidgets | Whether to close the widgets on value selection. Note: It's recommended to use shouldCloseWidgets function instead. | true | false | | customInputsForm | form attribute for the custom day, month, year, hour, minute, second, and AM/PM inputs. Set to an empty string to exclude these inputs from their nearest ancestor form.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

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

> 标签

TypeScriptcalendardatedate-pickerdaterange

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

> 工具信息

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

> 相关工具

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