TimeInput

free

TimeInput captures single times or ranges with segmented keyboard-friendly fields.

:
import TimeInput from '@/components/ui/time-input';

export default function UsageDemo() {
  return (

Installation

Add this component with the NateUI CLI.

npx nateui@latest add TimeInput

Examples

Basic

:
import TimeInput from '@/components/ui/time-input';

export default function BasicDemo() {
  return (

Time Range Input

:
~
:
import dayjs from 'dayjs';
import TimeInput from '@/components/ui/time-input';

export default function TimeRangeInputDemo() {

Controlled

:
:
~
:
Single: 09:00 AM / Range: 09:00 AM -10:00 AM
import { useState } from 'react';
import dayjs from 'dayjs';
import TimeInput from '@/components/ui/time-input';

Seconds

: :
import TimeInput from '@/components/ui/time-input';

export default function SecondsDemo() {
  return (

AM PM

:
import TimeInput from '@/components/ui/time-input';

export default function AmPmDemo() {
  return (

Sizes

:
:
:
import TimeInput from '@/components/ui/time-input';

export default function SizesDemo() {
  return (

Disabled

:
import TimeInput from '@/components/ui/time-input';

export default function DisabledDemo() {
  return (

Affix

UTC
:
:
Local
import TimeInput from '@/components/ui/time-input';

export default function AffixDemo() {
  return (

Invalid

:
import TimeInput from '@/components/ui/time-input';

export default function InvalidDemo() {
  return (

API

TimeInput uses separate fields for hours, minutes, optional seconds, and optional AM/PM. Arrow keys increment or decrement the focused segment.

TimeInput

PropDescriptionTypeDefault
amLabelText accepted and displayed for AM in 12-hour mode.string'am'
amPmPlaceholderPlaceholder for the AM/PM field.string'am'
clearableShows a clear button after a value exists.booleantrue
defaultValueInitial uncontrolled value.TimeInputValue-
disabledDisables every time segment and wrapper interaction.booleanfalse
embeddedRenders only the inner time fields, without InputWrapper.booleanfalse
formatSelects 12-hour or 24-hour fields.TimeInputFormat'24'
idId used for the first time field.stringgenerated
invalidApplies invalid input styling.boolean-
nameName applied to the hours field.string-
nextRefField to focus after the final time segment.RefObject<HTMLInputElement | null>-
onChangeCalled with the next date value, or null after clear.TimeInputChangeHandler-
pmLabelText accepted and displayed for PM in 12-hour mode.string'pm'
prefixPrefix content rendered inside the input wrapper.string | ReactNode-
refRef forwarded to the first time field.Ref<HTMLInputElement>-
showSecondsAdds a seconds field after minutes.booleanfalse
sizeInput wrapper size.ControlSize'md'
suffixSuffix content rendered inside the input wrapper.string | ReactNodeclock icon
timeFieldClassClass names applied to each time segment field.string-
timeFieldPlaceholderPlaceholder for hour, minute, and second fields.string'--'
valueControlled value.TimeInputValue-
...nativePropsNative props for the wrapper span.ComponentPropsWithRef<'span'>-

TimeInput.TimeInputRange

PropDescriptionTypeDefault
amPmPlaceholderPlaceholder for each AM/PM field.string'am'
clearableShows a clear button for the range.booleanfalse
defaultValueInitial uncontrolled start and end values.TimeInputRangeValue[null, null]
disabledDisables both time inputs.booleanfalse
formatSelects 12-hour or 24-hour fields.TimeInputFormat'24'
idId used for the first range field.stringgenerated
invalidApplies invalid input styling.boolean-
nameName applied to the first range field.string-
onChangeCalled with the next [start, end] range.TimeInputRangeChangeHandler-
prefixPrefix content rendered inside the range wrapper.string | ReactNode-
refRef forwarded to the first time field.Ref<HTMLInputElement>-
seperatorText rendered between the start and end fields.string'~'
showSecondsAdds seconds fields to both start and end inputs.booleanfalse
sizeInput wrapper size.ControlSize'md'
suffixSuffix content rendered inside the range wrapper.string | ReactNodeclock icon
timeFieldClassClass names applied to each time segment field.string-
timeFieldPlaceholderPlaceholder for hour, minute, and second fields.string'--'
valueControlled range value.TimeInputRangeValue-
...nativePropsNative props for the wrapper span.ComponentPropsWithRef<'span'>-

Types

type TimeInputValue = Date | null;
type TimeInputRangeValue = [Date | null, Date | null];
type TimeInputFormat = '12' | '24';
type ControlSize = 'sm' | 'md' | 'lg';
type TimeInputChangeHandler = (value: TimeInputValue) => void;
type TimeInputRangeChangeHandler = (value: TimeInputRangeValue) => void;