TimeInput

Capture time from the user using native browser time input. This component is re-exported from @mantine/dates via @tidbcloud/uikit.

Import

import { TimeInput } from '@tidbcloud/uikit'

Basic Usage

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

Controlled

import { useState } from 'react'
import { TimeInput } from '@tidbcloud/uikit'
 
function Demo() {
  const [value, setValue] = useState('')
  return (
    <TimeInput value={value} onChange={(event) => setValue(event.currentTarget.value)} label="Controlled time input" />
  )
}

With Seconds

import { TimeInput } from '@tidbcloud/uikit'
 
function Demo() {
  return <TimeInput label="With seconds" withSeconds />
}

With Icon

import { TimeInput } from '@tidbcloud/uikit'
import { IconClock } from '@tabler/icons-react'
 
function Demo() {
  return <TimeInput label="Select time" leftSection={<IconClock size={16} />} />
}

Show Browser Picker

import { useRef } from 'react'
import { TimeInput, ActionIcon } from '@tidbcloud/uikit'
import { IconClock } from '@tabler/icons-react'
 
function Demo() {
  const ref = useRef<HTMLInputElement>(null)
 
  return (
    <TimeInput
      label="Click icon to show picker"
      ref={ref}
      rightSection={
        <ActionIcon variant="subtle" onClick={() => ref.current?.showPicker()}>
          <IconClock size={16} />
        </ActionIcon>
      }
    />
  )
}

Key Props

PropTypeDescription
valuestringControlled value
defaultValuestringDefault value (uncontrolled)
onChange(event) => voidCalled when value changes
withSecondsbooleanShow seconds input
minTimestringMinimum time (HH:mm or HH:mm:ss)
maxTimestringMaximum time (HH:mm or HH:mm:ss)
labelReactNodeInput label
descriptionReactNodeInput description
placeholderstringPlaceholder text
errorReactNodeError message
disabledbooleanDisable input
sizeMantineSizeInput size
radiusMantineRadiusBorder radius