Gathering detailed insights and metrics for @uiw/react-time-picker
Gathering detailed insights and metrics for @uiw/react-time-picker
Gathering detailed insights and metrics for @uiw/react-time-picker
Gathering detailed insights and metrics for @uiw/react-time-picker
⚛️ @uiwjs A high quality UI Toolkit, A Component Library for React 16+.
npm install @uiw/react-time-picker
Typescript
Module System
Node Version
NPM Version
TypeScript (78.99%)
Less (20.49%)
JavaScript (0.38%)
HTML (0.12%)
Shell (0.01%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
736 Stars
3,301 Commits
121 Forks
31 Watchers
15 Branches
25 Contributors
Updated on Jul 03, 2025
Latest Version
4.22.3
Package Id
@uiw/react-time-picker@4.22.3
Unpacked Size
45.28 kB
Size
8.86 kB
File Count
26
NPM Version
9.8.1
Node Version
18.18.2
Published on
Nov 29, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
当用户需要输入一个时间,可以点击标准输入框,弹出时间面板进行选择。
1import { TimePicker } from 'uiw'; 2// or 3import TimePicker from '@uiw/react-time-picker';
1import React from 'react'; 2import { TimePicker, Row, Col } from 'uiw'; 3 4const Demo = () => ( 5 <Row gutter={10}> 6 <Col style={{ width: 200 }} fixed> 7 <TimePicker 8 onChange={(formatDate, date) => { 9 console.log('--->', formatDate, date); 10 }} 11 /> 12 </Col> 13 <Col style={{ width: 200 }} fixed> 14 <TimePicker format="HH:mm" precision="minute" /> 15 </Col> 16 <Col style={{ width: 200 }} fixed> 17 <TimePicker format="HH" precision="hour" /> 18 </Col> 19 </Row> 20) 21export default Demo;
1import React from 'react'; 2import { TimePicker, Row, Col } from 'uiw'; 3 4const Demo = () => { 5 const value = new Date(2018, 1, 24, 4,5,35); 6 return ( 7 <Row gutter={10}> 8 <Col style={{ width: 200 }} fixed> 9 <TimePicker value={value} /> 10 </Col> 11 <Col style={{ width: 200 }} fixed> 12 <TimePicker value={value} format="HH:mm" precision="minute" /> 13 </Col> 14 <Col style={{ width: 200 }} fixed> 15 <TimePicker value={value} format="HH" precision="hour" /> 16 </Col> 17 </Row> 18 ) 19} 20export default Demo;
1import React from 'react'; 2import { TimePicker, Row, Col } from 'uiw'; 3 4const Demo = () => { 5 const value = new Date(2018, 1, 24, 4,5,35); 6 return ( 7 <Row gutter={10}> 8 <Col style={{ width: 200 }} fixed> 9 <TimePicker size="small" value={value} /> 10 </Col> 11 <Col style={{ width: 200 }} fixed> 12 <TimePicker value={value} format="HH" precision="hour" /> 13 </Col> 14 <Col style={{ width: 200 }} fixed> 15 <TimePicker size="large" value={value} format="HH:mm" precision="minute" /> 16 </Col> 17 </Row> 18 ) 19} 20export default Demo;
在表单返回的数据,并没有将 format
格式化后的数据返回给你,而是返回的一个 Date
,你可以通过 formatter
重新格式化。
1import React from 'react'; 2import { TimePicker, Notify, Row, Col, Form, Button } from 'uiw'; 3 4const Demo = () => ( 5 <div> 6 <Form 7 onSubmit={({initial, current}) => { 8 console.log('-->>', initial, current); 9 if(current.date) { 10 Notify.success({ 11 title: '提交成功!', 12 description: `表单提交时间成功,时间为:${formatter('HH:mm:ss', current.date)}`, 13 }); 14 } else { 15 Notify.error({ 16 title: '提交失败!', 17 description: <span>表单提交时间成功,时间为:<b>空</b>,将自动填充初始化值!</span>, 18 }); 19 } 20 }} 21 fields={{ 22 date: { 23 labelClassName: 'fieldLabel', 24 labelFor: 'date-inline', 25 children: <TimePicker /> 26 }, 27 }} 28 > 29 {({ fields, state, canSubmit }) => { 30 return ( 31 <Row gutter={10}> 32 <Col style={{ width: 200 }} fixed>{fields.date}</Col> 33 <Col> 34 <Button disabled={!canSubmit()} type="primary" htmlType="submit">提交</Button> 35 </Col> 36 </Row> 37 ) 38 }} 39 </Form> 40 </div> 41) 42export default Demo;
可以使用 disabledHours
disabledMinutes
disabledSeconds
禁用部分时间选择。
1import React from 'react'; 2import { TimePicker, Row, Col } from 'uiw'; 3 4const Demo = () => ( 5 <Row gutter={10} style={{ maxWidth: 360 }}> 6 <Col style={{ width: 200 }} fixed> 7 <TimePicker 8 disabledMinutes={(minute, type) => { 9 if (minute % 15 !== 0) { 10 return true; 11 } 12 }} 13 disabledHours={(hour, type, date) => { 14 // console.log('~~:', hour, type, date); 15 if (hour < 3) { 16 return true; 17 } 18 }} 19 /> 20 </Col> 21 <Col style={{ width: 200 }} fixed> 22 <TimePicker disabled value={new Date(2018, 1, 24, 4,5,35)} /> 23 </Col> 24 </Row> 25) 26export default Demo;
可以使用 hideDisabled
将禁用的部分时间隐藏。
1import React from 'react'; 2import { TimePicker, Row, Col } from 'uiw'; 3 4const Demo = () => ( 5 <Row gutter={10} style={{ maxWidth: 360 }}> 6 <Col style={{ width: 200 }} fixed> 7 <TimePicker 8 hideDisabled 9 disabledMinutes={(minute, type) => { 10 if (minute % 15 !== 0) { 11 return true; 12 } 13 }} 14 disabledHours={(hour, type, date) => { 15 // console.log('~~:', hour, type, date); 16 if (hour < 3) { 17 return true; 18 } 19 }} 20 /> 21 </Col> 22 </Row> 23) 24export default Demo;
可以使用 hideDisabled
将禁用的部分时间隐藏。
1import React from 'react'; 2import { TimePicker, Row, Col } from 'uiw'; 3 4const Demo = () => ( 5 <Row gutter={10} style={{ maxWidth: 360 }}> 6 <Col style={{ width: 200 }} fixed> 7 <TimePicker 8 hideDisabled 9 disabledMinutes={(minute, date) => { 10 if (minute % 15 !== 0) { 11 return true; 12 } 13 }} 14 disabledSeconds={(second, date) => { 15 if (second % 15 !== 0) { 16 return true; 17 } 18 }} 19 /> 20 </Col> 21 </Row> 22) 23export default Demo;
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
value | 初始时间值 | Date | - |
placeholder | 输入框提示文字 | String | - |
format | 格式化时间,规则查看 formatter 文档 | Function | HH:mm:ss |
precision | 选择时间精确度 | Enum{hour , minute , second } | false |
disabled | 禁用全部操作 | Boolean | false |
disabledHours | 禁止选择部分小时选项 | Function(hour, type{ Hours , Minutes , Seconds }, selectedDate) | - |
disabledMinutes | 禁止选择部分分钟选项 | Function(minute, type{ Hours , Minutes , Seconds }, selectedDate) | - |
disabledSeconds | 禁止选择部分秒选项 | Function(second, type{ Hours , Minutes , Seconds }, selectedDate) | - |
hideDisabled | 不可选择的项隐藏 | Boolean | false |
onChange | 时间选择的回调函数 | Function(formatDate, Date, type{ Hours , Minutes , Seconds }, , num, disableds) | - |
uiw@3.3.0+
组件集成部分 Input,不再通过 inputProps 属性传值,更多属性请参考 Input
uiw@3.3.0+
将不支持此属性
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
<Input> 组件 | Object | - |
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
popoverProps | 将参数传递给 <Popover> 组件 | Object | - |
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
Found 1/26 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More