TimeRangeField

A segmented time range input with start and end time segments. Each part of both times is individually editable.

Example

Time range

Range: 09:00 to 17:00

Root Props

PropTypeDefaultDescription
value{ start: TimeValue; end: TimeValue }Selected time range, bindable
onValueChange(value) => voidCalled when range changes
placeholderTimeValuePlaceholder time, bindable
minValueTimeValueMinimum allowed time
maxValueTimeValueMaximum allowed time
disabledbooleanfalseDisable the field
readonlybooleanfalseMake the field read-only
localestring'en'Locale for segment formatting
granularity'hour' | 'minute' | 'second'Finest unit to display
hourCycle12 | 2412 or 24-hour time format
hideTimeZonebooleanfalseHide time zone segment
requiredbooleanfalseMark as required
onStartValueChange(value) => voidCalled when start time changes
onEndValueChange(value) => voidCalled when end time changes

Sub-components

ComponentKey PropsDescription
TimeRangeField.LabelclassLabel for the field
TimeRangeField.Inputtype, name, classSegmented time input for start or end (type="start" | "end")
TimeRangeField.Segmentpart, classIndividual time segment

Usage

<script>
  import { TimeRangeField } from '@chrissnell/chonky-ui';
  import { Time } from '@internationalized/date';

  let value = $state({
    start: new Time(9, 0),
    end: new Time(17, 0)
  });
</script>

<TimeRangeField.Root bind:value>
  <TimeRangeField.Label>Time range</TimeRangeField.Label>
  <div style="display: flex; align-items: center; gap: 0.25rem;">
    <TimeRangeField.Input type="start" />
    <span class="time-range-field-separator">–</span>
    <TimeRangeField.Input type="end" />
  </div>
</TimeRangeField.Root>