Skip to content

Time Range Field

Enter start and end times.

Demos

Size

Usage

vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'

const items = [
  { value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>

<template>
  <Accordion :items="items" />
</template>

Installation

Complete the shared installation. Copy TimeRangeField.vue and index.ts into app/components/ui/time-range-field/. Also copy the required components: Time Field.

API

Variants and defaults

PropValuesDefault
sizexs, sm, md, lg, xlsm

Models

ModelTypeDefaultDescription
v-modelTimeRange{}Optional start and end TimeValues. Partial segment text stays internal.
v-model:placeholderTimeValue | undefinedplaceholderShared base value for both endpoints.

Props

PropTypeDefaultDescription
idstringField id or generatedStart field id; end adds -end.
namestringField nameDerives .start and .end form names.
startName / endNamestringderivedExplicit native form names.
localestring"en-US"Segment order, labels, and default hour cycle.
dir"ltr" | "rtl""ltr"Reading direction.
placeholderTimeValuemidnightShared base time and value type.
minValue / maxValueTimeValue—Endpoint boundaries.
isTimeUnavailable(time) => boolean—Endpoint application constraint.
granularity"hour" | "minute" | "second""minute"Smallest endpoint unit.
hourCycle12 | 24locale preferenceExplicit hour cycle.
hideTimeZonebooleanfalseHides zoned endpoint labels.
step{ hour?, minute?, second? }each 1Endpoint keyboard step.
stepSnappingbooleanfalseSnaps complete endpoint values.
requiredbooleanfalseRequires both endpoints.
disabledbooleanfalseDisables endpoints and form submission.
readOnlybooleanfalseAllows focus but blocks edits.
invalidbooleanfalseForces invalid presentation.
selectOnFocusbooleantrueSelects focused segment text.
autoAdvancebooleantrueAdvances after two digits.
startLabelstring"Start time"Accessible start label.
endLabelstring"End time"Accessible end label.
ariaLabelstring"Time range"Root label without Field label relation.
ariaLabelledby / ariaDescribedbystringField relationsExplicit ARIA relationships.
uiTimeRangeFieldUi—Classes for range and endpoint parts.

Slots

SlotPropsDescription
start-literal / end-literalvalueEndpoint locale separators.
start-day-period / end-day-periodvalue, label, toggleEndpoint AM/PM content.
start-time-zone / end-time-zonevalueEndpoint zone content.
separator—Visual separator; hidden from assistive technology.

Events

EventPayloadDescription
update:modelValueTimeRangeFires after accepted endpoint changes.
update:placeholderTimeValue | undefinedFires after accepted placeholder changes.
value-change(range, details)Cancelable proposed range update.
value-commit(range, details)Accepted endpoint commit with prefixed reason.

Keyboard

Each endpoint uses Time Field keyboard behavior:

KeyBehavior
Number keys / pasteEdits focused endpoint segment.
ArrowUp / ArrowDownSteps segment.
PageUp / PageDownSteps by ten increments.
Home / EndSets segment boundary.
ArrowLeft / ArrowRightMoves within current endpoint.
Tab / Shift + TabUses native order across both endpoints and surrounding controls.
A / PSets focused endpoint day period.

Mouse and touch edit the native inputs and day-period buttons. The component does not require hover input.