logoAnt Design

⌘ K
  • 디자인
  • 개발
  • 컴포넌트
  • 블로그
  • 자료
5.21.3
  • Components Overview
  • General
    • Button
    • FloatButton
      5.0.0
    • Icon
    • Typography
  • Layout
    • Divider
    • Flex
      5.10.0
    • Grid
    • Layout
    • Space
    • Splitter
      5.21.0
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
  • Data Entry
    • AutoComplete
    • Cascader
    • Checkbox
    • ColorPicker
      5.5.0
    • DatePicker
    • Form
    • Input
    • InputNumber
    • Mentions
    • Radio
    • Rate
    • Select
    • Slider
    • Switch
    • TimePicker
    • Transfer
    • TreeSelect
    • Upload
  • Data Display
    • Avatar
    • Badge
    • Calendar
    • Card
    • Carousel
    • Collapse
    • Descriptions
    • Empty
    • Image
    • List
    • Popover
    • QRCode
      5.1.0
    • Segmented
    • Statistic
    • Table
    • Tabs
    • Tag
    • Timeline
    • Tooltip
    • Tour
      5.0.0
    • Tree
  • Feedback
    • Alert
    • Drawer
    • Message
    • Modal
    • Notification
    • Popconfirm
    • Progress
    • Result
    • Skeleton
    • Spin
    • Watermark
      5.1.0
  • Other
    • Affix
    • App
      5.1.0
    • ConfigProvider
    • Util
      5.13.0

TimePicker

To select/input a time.
가져오기import{ TimePicker }from"antd";
소스components/time-picker
문서
이 페이지 수정변경 로그

Resources

Ant Design Charts
Ant Design Pro
Ant Design Pro Components
Ant Design Mobile
Ant Design Mini
Ant Design Landing-Landing Templates
Scaffolds-Scaffold Market
Umi-React Application Framework
dumi-Component doc generator
qiankun-Micro-Frontends Framework
ahooks-React Hooks Library
Ant Motion-Motion Solution
China Mirror 🇨🇳

Community

Awesome Ant Design
Medium
Twitter
yuque logoAnt Design in YuQue
Ant Design in Zhihu
Experience Cloud Blog
seeconf logoSEE Conf-Experience Tech Conference
Work with Us

Help

GitHub
Change Log
FAQ
Bug Report
Issues
Discussions
StackOverflow
SegmentFault

Ant XTech logoMore Products

yuque logoYuQue-Document Collaboration Platform
AntV logoAntV-Data Visualization
Egg logoEgg-Enterprise Node.js Framework
Kitchen logoKitchen-Sketch Toolkit
Galacean logoGalacean-Interactive Graphics Solution
xtech logoAnt Financial Experience Tech
Theme Editor
Made with ❤ by
Ant Group and Ant Design Community
loading

When To Use

By clicking the input box, you can select a time from a popup panel.

Examples

API


Common props ref:Common props

import dayjs from 'dayjs';
import customParseFormat from 'dayjs/plugin/customParseFormat'
dayjs.extend(customParseFormat)
<TimePicker defaultValue={dayjs('13:30:56', 'HH:mm:ss')} />;
PropertyDescriptionTypeDefaultVersion
allowClearCustomize clear iconboolean | { clearIcon?: ReactNode }true5.8.0: Support object type
autoFocusIf get focus when component mountedbooleanfalse
cellRenderCustom rendering function for picker cells(current: number, info: { originNode: React.ReactElement, today: dayjs, range?: 'start' | 'end', subType: 'hour' | 'minute' | 'second' | 'meridiem' }) => React.ReactNode-5.4.0
changeOnScrollTrigger selection when scroll the columnbooleanfalse5.14.0
classNameThe className of pickerstring-
defaultValueTo set default timedayjs-
disabledDetermine whether the TimePicker is disabledbooleanfalse
disabledTimeTo specify the time that cannot be selectedDisabledTime-4.19.0
formatTo set the time formatstringHH:mm:ss
getPopupContainerTo set the container of the floating layer, while the default is to create a div element in bodyfunction(trigger)-
hideDisabledOptionsWhether hide the options that can not be selectedbooleanfalse
hourStepInterval between hours in pickernumber1
inputReadOnlySet the readonly attribute of the input tag (avoids virtual keyboard on touch devices)booleanfalse
minuteStepInterval between minutes in pickernumber1
needConfirmNeed click confirm button to trigger value changeboolean-5.14.0
openWhether to popup panelbooleanfalse
placeholderDisplay when there's no valuestring | [string, string]Select a time
placementThe position where the selection box pops upbottomLeft bottomRight topLeft topRightbottomLeft
popupClassNameThe className of panelstring-
popupStyleThe style of panelCSSProperties-
renderExtraFooterCalled from time picker panel to render some addon to its bottom() => ReactNode-
secondStepInterval between seconds in pickernumber1
showNowWhether to show Now button on panelboolean-4.4.0
sizeTo determine the size of the input box, the height of large and small, are 40px and 24px respectively, while default size is 32pxlarge | middle | small-
statusSet validation status'error' | 'warning' | 'success' | 'validating'-4.19.0
suffixIconThe custom suffix iconReactNode-
use12HoursDisplay as 12 hours format, with default format h:mm:ss abooleanfalse
valueTo set timedayjs-
variantVariants of pickeroutlined | borderless | filledoutlined5.13.0
onCalendarChangeCallback function, can be executed when the start time or the end time of the range is changing. info argument is added in 4.4.0function(dates: [dayjs, dayjs], dateStrings: [string, string], info: { range:start|end })-
onChangeA callback function, can be executed when the selected time is changingfunction(time: dayjs, timeString: string): void-
onOpenChangeA callback function which will be called while panel opening/closing(open: boolean) => void-

DisabledTime

type DisabledTime = (now: Dayjs) => {
disabledHours?: () => number[];
disabledMinutes?: (selectedHour: number) => number[];
disabledSeconds?: (selectedHour: number, selectedMinute: number) => number[];
disabledMilliseconds?: (
selectedHour: number,
selectedMinute: number,
selectedSecond: number,
) => number[];
};

Note: disabledMilliseconds is added in 5.14.0.

Methods

NameDescriptionVersion
blur()Remove focus
focus()Get focus

RangePicker

Same props from RangePicker of DatePicker. And includes additional props:

PropertyDescriptionTypeDefaultVersion
disabledTimeTo specify the time that cannot be selectedRangeDisabledTime-4.19.0
orderOrder start and end timebooleantrue4.1.0

RangeDisabledTime

type RangeDisabledTime = (
now: Dayjs,
type = 'start' | 'end',
) => {
disabledHours?: () => number[];
disabledMinutes?: (selectedHour: number) => number[];
disabledSeconds?: (selectedHour: number, selectedMinute: number) => number[];
};

Design Token

컴포넌트 토큰어떻게 사용하나요?

토큰 이름설명타입기본값
activeBg输入框激活状态时背景颜色string#ffffff
activeBorderColor激活态边框色string#1677ff
activeShadow激活态阴影string0 0 0 2px rgba(5, 145, 255, 0.1)
addonBg前/后置标签背景色stringrgba(0, 0, 0, 0.02)
cellActiveWithRangeBg选取范围内的单元格背景色string#e6f4ff
cellBgDisabled单元格禁用态背景色stringrgba(0, 0, 0, 0.04)
cellHeight单元格高度number24
cellHoverBg单元格悬浮态背景色stringrgba(0, 0, 0, 0.04)
cellHoverWithRangeBg选取范围内的单元格悬浮态背景色string#c8dfff
cellRangeBorderColor选取范围时单元格边框色string#7cb3ff
cellWidth单元格宽度number36
errorActiveShadow错误状态时激活态阴影string0 0 0 2px rgba(255, 38, 5, 0.06)
hoverBg输入框hover状态时背景颜色string#ffffff
hoverBorderColor悬浮态边框色string#4096ff
inputFontSize字体大小number14
inputFontSizeLG大号字体大小number16
inputFontSizeSM小号字体大小number14
multipleItemBg다중 선택 태그의 배경색stringrgba(0, 0, 0, 0.06)
multipleItemBorderColor다중 선택 태그의 테두리 색상stringtransparent
multipleItemBorderColorDisabled비활성화된 경우 다중 선택 태그의 테두리 색상stringtransparent
multipleItemColorDisabled비활성화된 경우 다중 선택 태그의 텍스트 색상stringrgba(0, 0, 0, 0.25)
multipleItemHeight다중 선택 태그의 높이number24
multipleItemHeightLG큰 크기의 다중 선택 태그의 높이number32
multipleItemHeightSM작은 크기의 다중 선택 태그의 높이number16
multipleSelectorBgDisabled비활성화된 경우 다중 선택기의 배경색stringrgba(0, 0, 0, 0.04)
paddingBlock输入框纵向内边距number4
paddingBlockLG大号输入框纵向内边距number7
paddingBlockSM小号输入框纵向内边距number0
paddingInline输入框横向内边距number11
paddingInlineLG大号输入框横向内边距number11
paddingInlineSM小号输入框横向内边距number7
presetsMaxWidth预设区域最大宽度number200
presetsWidth预设区域宽度number120
textHeight单元格文本高度number40
timeCellHeight时间单元格高度number28
timeColumnHeight时间列高度number224
timeColumnWidth时间列宽度number56
warningActiveShadow警告状态时激活态阴影string0 0 0 2px rgba(255, 215, 5, 0.1)
withoutTimeCellHeight十年/年/季/月/周单元格高度number66
zIndexPopup弹窗 z-indexnumber1050

글로벌 토큰어떻게 사용하나요?

FAQ

  • How to use TimePicker with customize date library like dayjs
Basic
codepen icon
External Link Icon
expand codeexpand code
Three Sizes
codepen icon
External Link Icon
expand codeexpand code
disabled
codepen icon
External Link Icon
expand codeexpand code
interval option
codepen icon
External Link Icon
expand codeexpand code
12 hours
codepen icon
External Link Icon
expand codeexpand code
Colored Popup
codepen icon
External Link Icon
expand codeexpand code
Variants
codepen icon
External Link Icon
expand codeexpand code
5.13.0
Suffix
codepen icon
External Link Icon
expand codeexpand code
Under Control
codepen icon
External Link Icon
expand codeexpand code
Need Confirm
codepen icon
External Link Icon
expand codeexpand code
5.14.0
Hour and minute
codepen icon
External Link Icon
expand codeexpand code
Addon
codepen icon
External Link Icon
expand codeexpand code
Change on scroll
codepen icon
External Link Icon
expand codeexpand code
5.14.0
Time Range Picker
codepen icon
External Link Icon
expand codeexpand code
Status
codepen icon
External Link Icon
expand codeexpand code
_InternalPanelDoNotUseOrYouWillBeFired
codepen icon
External Link Icon
expand codeexpand code