DateTimePicker

Capture datetime from the user.

Import

import { DateTimePicker } from '@tidbcloud/uikit'

Usage

import { DateTimePicker } from '@tidbcloud/uikit'
 
function Demo() {
  return <DateTimePicker label="Pick date and time" placeholder="Pick date and time" />
}

With seconds

Set withSeconds prop to display seconds input:

import { DateTimePicker } from '@tidbcloud/uikit'
 
function Demo() {
  return <DateTimePicker withSeconds label="Pick date and time" placeholder="Pick date and time" />
}

Value format

Use valueFormat prop to change dayjs format of value label:

import { DateTimePicker } from '@tidbcloud/uikit'
 
function Demo() {
  return (
    <DateTimePicker valueFormat="DD MMM YYYY hh:mm A" label="Pick date and time" placeholder="Pick date and time" />
  )
}

Clearable

Set clearable prop to display clear button:

import { DateTimePicker } from '@tidbcloud/uikit'
 
function Demo() {
  return <DateTimePicker clearable label="Pick date and time" placeholder="Pick date and time" />
}

Open picker in modal

Set dropdownType="modal" to render picker in a modal:

import { DateTimePicker } from '@tidbcloud/uikit'
 
function Demo() {
  return <DateTimePicker dropdownType="modal" label="Pick date and time" placeholder="Pick date and time" />
}

TimePicker props

You can pass props to the underlying TimePicker component with timePickerProps:

import { DateTimePicker } from '@tidbcloud/uikit'
 
function Demo() {
  return (
    <DateTimePicker
      label="Pick date and time"
      placeholder="Pick date and time"
      timePickerProps={{
        withDropdown: true,
        format: '12h'
      }}
    />
  )
}

Disabled state

import { DateTimePicker } from '@tidbcloud/uikit'
 
function Demo() {
  return <DateTimePicker label="Disabled" placeholder="Pick date and time" disabled />
}

Props

PropTypeDefaultDescription
valuestring | null-Controlled value
defaultValuestring-Default value
onChange(value: string | null) => void-Called when value changes
valueFormatstring-dayjs format for display
withSecondsbooleanfalseDisplay seconds input
clearablebooleanfalseShow clear button
dropdownType’popover’ | ‘modal''popover’Type of dropdown
timePickerPropsTimePickerProps-Props for TimePicker
minDatestring-Minimum allowed date
maxDatestring-Maximum allowed date
labelReactNode-Input label
descriptionReactNode-Input description
errorReactNode-Error message
disabledbooleanfalseDisable input
placeholderstring-Input placeholder
sizeMantineSize’sm’Input size
localestring’en’dayjs locale