logoAnt Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
YouMindTRACTIANLobeHubCodeRabbit
6.5.0
  • Components Overview
  • Changelog
    v6.5.0
  • General
    • Button
    • FloatButton
    • Icon
    • Typography
  • Layout
    • Divider
    • Flex
    • Grid
    • Layout
    • Masonry
      6.0.0
    • Space
    • Splitter
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
    • Tabs
  • Data Entry
    • AutoComplete
    • Cascader
    • Checkbox
    • ColorPicker
    • 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
      DEPRECATED
    • Popover
    • QRCode
    • Segmented
    • Statistic
    • Table
    • Tag
    • Timeline
    • Tooltip
    • Tour
    • Tree
  • Feedback
    • Alert
    • Drawer
    • Message
    • Modal
    • Notification
    • Popconfirm
    • Progress
    • Result
    • Skeleton
    • Spin
    • Watermark
  • Other
    • Affix
    • App
    • BorderBeam
      6.4.0
    • ConfigProvider
    • Util
When To Use
Examples
Basic
Under Control
Three Sizes
Need Confirm
disabled
Hour and minute
interval option
Addon
12 hours
Change on scroll
Time Range Picker
Variants
Status
Prefix and Suffix
Custom semantic dom styling
API
Methods
RangePicker
RangeDisabledTime
Semantic DOM
Design Token
FAQ

TimePicker

To select/input a time.
Importimport { TimePicker } from 'antd';
GitHub
components/time-pickerIssueOpen issues
Docs
Edit this pageLLMs.md
SwitchTransfer

Resources

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

Community

Awesome Ant Design
Medium
X
yuque logoAnt Design in YuQue
Ant Design in Zhihu
Experience Cloud Blog
seeconf logoSEE Conf-Experience Tech Conference

Help

GitHub
Change Log
FAQ
For Agents
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
WeaveFox logoWeaveFox-AI Development with WeaveFox 🦊
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

jsx
import dayjs from 'dayjs';
import customParseFormat from 'dayjs/plugin/customParseFormat'
dayjs.extend(customParseFormat)
<TimePicker defaultValue={dayjs('13:30:56', 'HH:mm:ss')} />;
PropertyDescriptionTypeDefaultVersionGlobal Config
allowClearCustomize clear iconboolean | { clearIcon?: ReactNode }true5.8.0: Support object type6.4.0
addonCalled from time picker panel to render an addon to its bottom, please use renderExtraFooter instead() => ReactNode--×
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×
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-5.25.0
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 panel, please use classNames.popup insteadstring-×
popupStyleThe style of panel, please use styles.popup insteadCSSProperties-×
prefixThe custom prefixReactNode-5.22.0×
previewValueWhen the user selects the time hover option, the value of the input field undergoes a temporary changefalse | hoverhover6.0.0×
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 | medium | small-×
statusSet validation status'error' | 'warning' | 'success' | 'validating'-4.19.0×
stylesCustomize inline style for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-5.25.0
suffixIconThe custom suffix iconReactNode-6.3.0
use12HoursDisplay as 12 hours format, with default format h:mm:ss abooleanfalse×
valueTo set timedayjs-×
variantVariants of pickeroutlined | borderless | filled | underlinedoutlined5.13.0 | underlined: 5.24.05.19.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-×
onClearCallback when click the clear button() => void-6.5.0×
onOpenChangeA callback function which will be called while panel opening/closing(open: boolean) => void-×

DisabledTime

typescript
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

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

Semantic DOM

Design Token

Component TokenHow to use?
Token NameDescriptionTypeDefault Value
activeBgBackground color when the input box is activatedstring#ffffff
activeBorderColorActive border colorstring#1677ff
activeShadowBox-shadow when activestring0 0 0 2px rgba(5,145,255,0.1)
addonBgBackground color of addonstringrgba(0,0,0,0.02)
cellActiveWithRangeBgBackground color of cell in rangestring#e6f4ff
cellBgDisabledBackground color of disabled cellstringrgba(0,0,0,0.04)
cellHeightHeight of cellnumber24
cellHoverBgBackground color of cell hover statestringrgba(0,0,0,0.04)
cellHoverWithRangeBgBackground color of hovered cell in rangestring#cbe0fd
cellRangeBorderColorBorder color of cell in range when pickingstring#82b4f9
cellWidthWidth of cellnumber36
errorActiveShadowBox-shadow when active in error statusstring0 0 0 2px rgba(255,38,5,0.06)
hoverBgBackground color when the input box hoversstring#ffffff
hoverBorderColorHover border colorstring#4096ff
inputFontSizeFont sizenumber14
inputFontSizeLGFont size of largenumber16
inputFontSizeSMFont size of smallnumber14
multipleItemBgBackground color of multiple tagstringrgba(0,0,0,0.06)
multipleItemBorderColorBorder color of multiple tagstringtransparent
multipleItemBorderColorDisabledBorder color of multiple tag when disabledstringtransparent
multipleItemColorDisabledText color of multiple tag when disabledstringrgba(0,0,0,0.25)
multipleItemHeightHeight of multiple tagnumber24
multipleItemHeightLGHeight of multiple tag with large sizenumber32
multipleItemHeightSMHeight of multiple tag with small sizenumber16
multipleSelectorBgDisabledBackground color of multiple selector when disabledstringrgba(0,0,0,0.04)
paddingBlockVertical padding of inputnumber4
paddingBlockLGVertical padding of large inputnumber7
paddingBlockSMVertical padding of small inputnumber0
paddingInlineHorizontal padding of inputnumber11
paddingInlineLGHorizontal padding of large inputnumber11
paddingInlineSMHorizontal padding of small inputnumber7
presetsMaxWidthMax width of preset areanumber200
presetsWidthWidth of preset areanumber120
textHeightHeight of cell textnumber40
timeCellHeightHeight of time cellnumber28
timeColumnHeightHeight of time columnnumber224
timeColumnWidthWidth of time columnnumber56
warningActiveShadowBox-shadow when active in warning statusstring0 0 0 2px rgba(255,215,5,0.1)
withoutTimeCellHeightHeight of decade/year/quarter/month/week cellnumber66
zIndexPopupz-index of popupnumber1050
Global TokenHow to use?
Token NameDescriptionTypeDefault Value
colorBgContainerContainer background color, e.g: default button, input box, etc. Be sure not to confuse this with `colorBgElevated`.string#ffffff
colorBgContainerDisabledControl the background color of container in disabled state.stringrgba(0,0,0,0.04)
colorBgElevatedContainer background color of the popup layer, in dark mode the color value of this token will be a little brighter than `colorBgContainer`. E.g: modal, pop-up, menu, etc.string#ffffff
colorBorderDefault border color, used to separate different elements, such as: form separator, card separator, etc.string#d9d9d9
colorBorderDisabledControl the border color of the element in the disabled state.string#d9d9d9
colorErrorUsed to represent the visual elements of the operation failure, such as the error Button, error Result component, etc.string#ff4d4f
colorErrorAffixControl the color of form control prefix/suffix in error state.string#ff4d4f
colorErrorBgThe background color of the error state.string#fff2f0
colorErrorBgHoverThe hover state background color of the error state.string#fff1f0
colorErrorBorderHoverThe hover state border color of the error state.string#ffa39e
colorErrorTextThe default state of the text in the error color.string#ff4d4f
colorFillSecondaryThe second level of fill color can outline the shape of the element more clearly, such as Rate, Skeleton, etc. It can also be used as the Hover state of the third level of fill color, such as Table, etc.stringrgba(0,0,0,0.06)
colorFillTertiaryThe third level of fill color is used to outline the shape of the element, such as Slider, Segmented, etc. If there is no emphasis requirement, it is recommended to use the third level of fill color as the default fill color.stringrgba(0,0,0,0.04)
colorIconWeak action. Such as `allowClear` or Alert close buttonstringrgba(0,0,0,0.45)
colorIconHoverWeak action hover color. Such as `allowClear` or Alert close buttonstringrgba(0,0,0,0.88)
colorPrimaryBrand color is one of the most direct visual elements to reflect the characteristics and communication of the product. After you have selected the brand color, we will automatically generate a complete color palette and assign it effective design semantics.string#1677ff
colorPrimaryBorderThe stroke color under the main color gradient, used on the stroke of components such as Slider.string#91caff
colorSplitUsed as the color of separator, this color is the same as colorBorderSecondary but with transparency.stringrgba(5,5,5,0.06)
colorTextDefault text color which comply with W3C standards, and this color is also the darkest neutral color.stringrgba(0,0,0,0.88)
colorTextDisabledControl the color of text in disabled state.stringrgba(0,0,0,0.25)
colorTextHeadingControl the font color of heading.stringrgba(0,0,0,0.88)
colorTextLightSolidControl the highlight color of text with background color, such as the text in Primary Button components.string#fff
colorTextPlaceholderControl the color of placeholder text.stringrgba(0,0,0,0.25)
colorTextQuaternaryThe fourth level of text color is the lightest text color, such as form input prompt text, disabled color text, etc.stringrgba(0,0,0,0.25)
colorTextTertiaryThe third level of text color is generally used for descriptive text, such as form supplementary explanation text, list descriptive text, etc.stringrgba(0,0,0,0.45)
colorWarningUsed to represent the warning map token, such as Notification, Alert, etc. Alert or Control component(like Input) will use these map tokens.string#faad14
colorWarningAffixControl the color of form control prefix/suffix in warning state.string#faad14
colorWarningBgThe background color of the warning state.string#fffbe6
colorWarningBgHoverThe hover state background color of the warning state.string#fff1b8
colorWarningBorderHoverThe hover state border color of the warning state.string#ffd666
colorWarningTextThe default state of the text in the warning color.string#faad14
borderRadiusBorder radius of base componentsnumber6
borderRadiusLGLG size border radius, used in some large border radius components, such as Card, Modal and other components.number8
borderRadiusSMSM size border radius, used in small size components, such as Button, Input, Select and other input components in small sizenumber4
borderRadiusXSXS size border radius, used in some small border radius components, such as Segmented, Arrow and other components with small border radius.number2
boxShadowSecondaryControl the secondary box shadow style of an element.string 0 6px 16px 0 rgba(0,0,0,0.08), 0 3px 6px -4px rgba(0,0,0,0.12), 0 9px 28px 8px rgba(0,0,0,0.05)
controlHeightThe height of the basic controls such as buttons and input boxes in Ant Designnumber32
controlHeightLGLG component heightnumber40
controlHeightSMSM component heightnumber24
controlItemBgActiveControl the background color of control component item when active.string#e6f4ff
fontFamilyThe font family of Ant Design prioritizes the default interface font of the system, and provides a set of alternative font libraries that are suitable for screen display to maintain the readability and readability of the font under different platforms and browsers, reflecting the friendly, stable and professional characteristics.string-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'
fontSizeThe most widely used font size in the design system, from which the text gradient will be derived.number14
fontSizeLGLarge font sizenumber16
fontSizeSMSmall font sizenumber12
fontWeightStrongControl the font weight of heading components (such as h1, h2, h3) or selected item.number600
lineHeightLine height of text.number1.5714285714285714
lineHeightLGLine height of large text.number1.5
lineTypeBorder style of base componentsstringsolid
lineWidthBorder width of base componentsnumber1
lineWidthBoldThe default line width of the outline class components, such as Button, Input, Select, etc.number2
lineWidthFocusControl the width of the line when the component is in focus state.number3
marginXSControl the margin of an element, with a small size.number8
marginXXSControl the margin of an element, with the smallest size.number4
motionDurationMidMotion speed, medium speed. Used for medium element animation interaction.string0.2s
motionDurationSlowMotion speed, slow speed. Used for large element animation interaction.string0.3s
motionEaseInOutCircPreset motion curve.string
Cubic Bezier Visualizer
cubic-bezier(0.78, 0.14, 0.15, 0.86)External Link Icon
motionEaseInQuintPreset motion curve.string
Cubic Bezier Visualizer
cubic-bezier(0.755, 0.05, 0.855, 0.06)External Link Icon
motionEaseOutCircPreset motion curve.string
Cubic Bezier Visualizer
cubic-bezier(0.08, 0.82, 0.17, 1)External Link Icon
motionEaseOutQuintPreset motion curve.string
Cubic Bezier Visualizer
cubic-bezier(0.23, 1, 0.32, 1)External Link Icon
paddingControl the padding of the element.number16
paddingSMControl the small padding of the element.number12
paddingXSControl the extra small padding of the element.number8
paddingXXSControl the extra extra small padding of the element.number4
sizePopupArrowThe size of the component arrownumber16

FAQ

  • How to use TimePicker with customize date library like dayjs
Basic

Click TimePicker, and then we could select or input a time in panel.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Three Sizes

The input box comes in three sizes: large, medium and small. Large is used in the form, while the medium size is the default.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
disabled

A disabled state of the TimePicker.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
interval option

Show stepped options by hourStep minuteStep secondStep.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
12 hours

TimePicker of 12 hours format, with default format h:mm:ss a.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Time Range Picker

Use time range picker with TimePicker.RangePicker.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Status

Add status to TimePicker with status, which could be error or warning.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Custom semantic dom styling

You can customize the semantic dom style of TimePicker by passing objects/functions through classNames and styles.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
6.0.0
Under Control

value and onChange should be used together,

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Need Confirm

TimePicker will automatically determine whether to show a confirm button according to the picker property. You can also set the needConfirm property to determine whether to show a confirm button. When needConfirm is set, the user must click the confirm button to complete the selection. Otherwise, the selection will be submitted when the picker loses focus or select a time.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
5.14.0
Hour and minute

While part of format is omitted, the corresponding column in panel will disappear, too.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Addon

Render addon contents to time picker panel's bottom.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Change on scroll

Use changeOnScroll and needConfirm to change the value when scrolling.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
5.14.0
Variants

Variants of TimePicker, there are four variants: outlined filled borderless and underlined.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
5.13.0
Prefix and Suffix

Custom prefix and suffixIcon.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
  • root
    Root element with relative positioning, inline-flex layout, padding, border-radius, transition animations and other basic styles for date picker container
  • prefix
    Prefix element with flex layout and margin styles for prefix content layout
  • input
    Input element with relative positioning, width, color, font, line-height, transition animations and other core interactive styles for input field
  • suffix
    Suffix element with flex layout, color, line-height, pointer events, transition animations and other styles for suffix content
  • popup.root
    Popup element
  • popup.container
    Container element, set background color, padding, border radius, shadow, border and content display styles
  • popup.content
    Popup content element with width, border, cell and other content display styles for date table
  • popup.item
    Popup item element with size, background, border-radius, hover state, selected state and other interactive styles for date cells
  • popup.footer
    Popup footer element with layout styles for bottom operation area including confirm/cancel buttons and shortcuts