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

react-available-times

> 编程语言
开源

一个日历,用于选择可用的时间段

99 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

一个日历,用于选择可用的时间段

React Available Times

A React component that allows a user to select time-slots in a calendar-like UI.

Installation

bash
npm install --save react-available-times

Usage

javascript
import AvailableTimes from 'react-available-times';

 {
    selections.forEach(({ start, end }) => {
      console.log('Start:', start, 'End:', end);
    })
  }}
  onEventsRequested={({ calendarId, start, end, callback }) => {
    loadMoreEvents(calendarId, start, end).then(callback);
  }}
  initialSelections={[
    { start: aDateObject, end: anotherDateObject }
  ]}
  height={400}
  recurring={false}
  availableDays={['monday', 'tuesday', 'wednesday', 'thursday', 'friday']}
  availableHourRange={{ start: 9, end: 19 }}
/>

Props

None of the props are required.

  • weekStartsOn: a string (either "monday" or "sunday") specifying what day of the week should come first.
  • calendars: a list of calendars displayed in the dropdown at the top right.
  • onChange: a function called whenever a selection is made. Receives an array of objects, each with a start and an end date.
  • onEventsRequested: a function called when new weeks are loaded. Hook in to this function to continuously feed events to the calendar view. The callback provided should be called when you have fetched events for the particular calendarId. Call the callback with an array of objects, where each object has a start and an end date, plus a title property. Can have a calendarId property tying them to a calendar, inheriting the foreground and background color. Can also have a allDay property, in which case they are rendered at the top.
  • initialSelections: an array of pre-filled selections. Each object in the array needs a start and an end date.
  • height: a string or a number controlling the height of the component. E.g. '100%', 350, '100vh'. If left out, the full height of the screen will be used.
  • recurring: set to true to turn the view into a selector for recurring availability. No dates are then shown, and the onChange callback is called with events that have a start and end expressed in number of minutes since the start of the week. The weekStartsOn prop is taken into account here, so the 0 minute is either monday at 00:00 or sunday at 00:00.
  • availableDays: an array of strings ("monday", "tuesday" ...) specifying what days of the week are available to be used. It is set to every day by default.
  • availableHourRange: an object with start and end numbers, ranging from 0 to 24 inclusive. Defaults to the entire day by default.

Contributing

First, run npm install to install all dependencies. Then, to manually test the component, run npm run start-test and open http://localhost:3333/ in a browser.

Unit tests are run with jest. Run npm run test -- --watch to run tests.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

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

> 标签

JavaScript

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

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言