Date & Time
TimeField
A segmented time input where each part (hour, minute, second, AM/PM) is edited independently. Locale-aware, keyboard-friendly, and ready for native form submission.
Playground
Experiment with different props in real-time.
0930AM
Basic Usage
Bind a Time value from @internationalized/date.
0930AM
<script lang="ts">
import { TimeField } from 'sv5ui';
import { Time } from '@internationalized/date';
let value = $state(new Time(9, 30));
</script>
<TimeField bind:value />Granularity
Control which segments render.
––AM
––––––AM
<!-- Hour only -->
<TimeField granularity="hour" />
<!-- Down to seconds -->
<TimeField granularity="second" />Hour Cycle
––––
––––AM
<!-- Force 24-hour clock -->
<TimeField hourCycle={24} />
<!-- Force 12-hour clock with AM/PM -->
<TimeField hourCycle={12} />Min & Max
Restrict the selectable range.
––––AM
<script lang="ts">
import { TimeField } from 'sv5ui';
import { Time } from '@internationalized/date';
</script>
<!-- Office hours only -->
<TimeField minValue={new Time(9)} maxValue={new Time(17)} />Without Icon
––––AM
<!-- Hide the decorative icon -->
<TimeField icon={false} />Variants
––––AM
––––AM
––––AM
––––AM
<TimeField variant="outline" />
<TimeField variant="soft" />
<TimeField variant="subtle" />
<TimeField variant="ghost" />Sizes
––––AM
––––AM
––––AM
<TimeField size="xs" />
<TimeField size="md" />
<TimeField size="xl" />Disabled & Readonly
0215PM
0215PM
<script lang="ts">
import { TimeField } from 'sv5ui';
import { Time } from '@internationalized/date';
</script>
<TimeField value={new Time(14, 15)} disabled />
<TimeField value={new Time(14, 15)} readonly />Form Field
––––AM
Please pick a time
<script lang="ts">
import { TimeField, FormField } from 'sv5ui';
import type { TimeValue } from 'bits-ui';
let time = $state<TimeValue | undefined>(undefined);
const error = $derived(time ? '' : 'Please pick a time');
</script>
<FormField label="Start time" {error}>
<TimeField bind:value={time} name="startTime" />
</FormField>UI Slots
Use the ui prop to override classes.
| Slot | Description |
|---|---|
root | The field wrapper |
base | The hidden native input |
field | The segmented field container |
segment | Each editable time segment |
literal | Separators between segments |
iconWrapper | The trailing icon wrapper |
icon | The decorative clock icon |
Props
| Prop | Type | Default |
|---|---|---|
value | TimeValue | - |
onValueChange | (value) => void | - |
placeholder | TimeValue | current time |
granularity | 'hour' | 'minute' | 'second' | 'minute' |
hourCycle | 12 | 24 | - |
hideTimeZone | boolean | false |
locale | string | 'en' |
minValue | TimeValue | - |
maxValue | TimeValue | - |
validate | TimeValidator | - |
onInvalid | TimeOnInvalid | - |
icon | string | false | 'lucide:clock' |
variant | 'outline' | 'soft' | 'subtle' | 'ghost' | 'none' | 'outline' |
color | ColorType | 'primary' |
size | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'md' |
disabled | boolean | false |
readonly | boolean | false |
required | boolean | false |
name | string | - |
highlight | boolean | false |
ref | HTMLElement | null | null |
class | string | - |
ui | Record<Slot, Class> | - |