logoAnt Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
5.26.1
  • 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
    • Tabs
  • 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
    • 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
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
API
Methods
RangePicker
RangeDisabledTime
Semantic DOM
Design Token
FAQ

TimePicker

To select/input a time.
Importimport { TimePicker } from "antd";
Sourcecomponents/time-picker
Docs
Edit this pageChangelog
contributors
  • 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
    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

    jsx
    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-
    prefixThe custom prefixReactNode-5.22.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 | 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 | filled | underlinedoutlined5.13.0 | underlined: 5.24.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

    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?

    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
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    Three Sizes

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

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    disabled

    A disabled state of the TimePicker.

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    interval option

    Show stepped options by hourStep minuteStep secondStep.

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    12 hours

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

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    Time Range Picker

    Use time range picker with TimePicker.RangePicker.

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    Status

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

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    Under Control

    value and onChange should be used together,

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    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
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    5.14.0
    Hour and minute

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

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    Addon

    Render addon contents to time picker panel's bottom.

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    Change on scroll

    Use changeOnScroll and needConfirm to change the value when scrolling.

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    5.14.0
    Variants

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

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    5.13.0
    Prefix and Suffix

    Custom prefix and suffixIcon.

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    • root
      5.25.0
      Root element
    • popup.root
      5.25.0
      Popup root element