Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e4c1e45
feat(InputTime): add component
hywax Oct 24, 2025
dce8077
feat(InputTime): enhance component with Time support and add InputTim…
hywax Oct 24, 2025
74bd137
test(InputTime): expand test cases for InputTime component with vario…
hywax Oct 24, 2025
00c5343
Merge branch 'v4' into input-time
hywax Nov 1, 2025
10ad31f
fix(InputTime): improve key handling and trim segment values in TimeF…
hywax Nov 1, 2025
a573428
docs(InputTime): update documentation to reflect hourCycle prop and r…
hywax Nov 1, 2025
fa460eb
refactor(InputTime): remove console.log statement from TimeFieldInput
hywax Nov 1, 2025
5bba77c
docs(InputTime): add defaultValue prop to InputTime documentation
hywax Nov 1, 2025
89d8249
test(InputTime): update snapshots to reflect changes in InputTime com…
hywax Nov 1, 2025
1b0346a
Apply suggestion from @vercel[bot]
hywax Nov 1, 2025
0a3272d
Merge branch 'v4' into input-time
benjamincanac Nov 4, 2025
30af604
clean
benjamincanac Nov 4, 2025
4799f21
Merge branch 'v4' into pr/5302
benjamincanac Nov 4, 2025
68929ae
docs: add images
benjamincanac Nov 4, 2025
bc4a79d
fix(InputTime): update snapshot tests to reflect changes in component…
hywax Nov 5, 2025
efca0ed
improve component theme
benjamincanac Nov 5, 2025
1278d32
docs: fix dir name
benjamincanac Nov 5, 2025
f5d532b
Merge branch 'v4' into pr/5302
benjamincanac Nov 5, 2025
f36ff83
fix: ignore `asChild`
benjamincanac Nov 5, 2025
6727838
test: update
benjamincanac Nov 5, 2025
6a79e77
fix: clean forward omit
benjamincanac Nov 5, 2025
d175ce3
docs: clean
benjamincanac Nov 5, 2025
6c9dd93
Update src/runtime/components/InputTime.vue
hywax Nov 5, 2025
4acf34a
feat(InputTime): add UIcon and UAvatar imports for enhanced functiona…
hywax Nov 5, 2025
1666d70
fix: use `text-muted` on literal segment
benjamincanac Nov 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion docs/app/components/content/ComponentCode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { ChipProps } from '@nuxt/ui'
import json5 from 'json5'
import { upperFirst, camelCase, kebabCase } from 'scule'
import { hash } from 'ohash'
import { CalendarDate } from '@internationalized/date'
import { CalendarDate, Time } from '@internationalized/date'
import * as theme from '#build/ui'
import { get, set } from '#ui/utils'

Expand All @@ -14,6 +14,7 @@ interface Cast {
}

type CastDateValue = [number, number, number]
type CastTimeValue = [number, number, number]

const castMap: Record<string, Cast> = {
'DateValue': {
Expand All @@ -37,6 +38,12 @@ const castMap: Record<string, Cast> = {

return `{ start: new CalendarDate(${value.start.year}, ${value.start.month}, ${value.start.day}), end: new CalendarDate(${value.end.year}, ${value.end.month}, ${value.end.day}) }`
}
},
'TimeValue': {
get: (args: CastTimeValue) => new Time(...args),
template: (value: Time) => {
return value ? `new Time(${value.hour}, ${value.minute}, ${value.second})` : 'null'
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script setup lang="ts">
import { Time } from '@internationalized/date'

const time = shallowRef(new Time(12, 30, 0))
</script>

<template>
<UFormField label="Time" help="Specify the time" required>
<UInputTime v-model="time" />
</UFormField>
</template>
181 changes: 181 additions & 0 deletions docs/content/docs/2.components/input-time.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
---
title: InputTime
description: 'An input for selecting a time.'
category: form
links:
- label: TimeField
icon: i-custom-reka-ui
to: https://reka-ui.com/docs/components/time-field
- label: GitHub
icon: i-simple-icons-github
to: https://github.com/nuxt/ui/blob/v4/src/runtime/components/InputTime.vue
navigation.badge: Soon
---

## Usage

Use the `v-model` directive to control the selected date.

::component-code
---
cast:
modelValue: TimeValue
ignore:
- modelValue
external:
- modelValue
props:
modelValue: [12, 30, 0]
---
::

Use the `default-value` prop to set the initial value when you do not need to control its state.

::component-code
---
cast:
defaultValue: TimeValue
ignore:
- defaultValue
external:
- defaultValue
props:
defaultValue: [12, 30, 0]
---
::

::note
This component relies on the [`@internationalized/date`](https://react-spectrum.adobe.com/internationalized/date/index.html) package which provides objects and functions for representing and manipulating dates and times in a locale-aware manner.
::

### Hour Cycle

Use the `hour-cycle` prop to change the hour cycle of the InputTime. Defaults to `12`.

::component-code
---
cast:
defaultValue: TimeValue
ignore:
- hourCycle
- defaultValue
external:
- defaultValue
props:
hourCycle: 24
defaultValue: [16, 30, 0]
---
::

### Color

Use the `color` prop to change the color of the InputTime.

::component-code
---
props:
color: neutral
highlight: true
---
::

::note
The `highlight` prop is used here to show the focus state. It's used internally when a validation error occurs.
::

### Variant

Use the `variant` prop to change the variant of the InputTime.

::component-code
---
props:
variant: subtle
---
::

### Size

Use the `size` prop to change the size of the InputTime.

::component-code
---
props:
size: xl
---
::

### Icon

Use the `icon` prop to show an [Icon](/docs/components/icon) inside the InputTime.

::component-code
---
props:
icon: 'i-lucide-clock'
---
::

::note
Use the `leading` and `trailing` props to set the icon position or the `leading-icon` and `trailing-icon` props to set a different icon for each position.
::

### Avatar

Use the `avatar` prop to show an [Avatar](/docs/components/avatar) inside the InputTime.

::component-code
---
prettier: true
props:
avatar:
src: 'https://github.com/vuejs.png'
size: md
variant: outline
---
::

### Disabled

Use the `disabled` prop to disable the InputTime.

::component-code
---
props:
disabled: true
---
::

## Examples

### Within a FormField

You can use the InputTime within a [FormField](/docs/components/form-field) component to display a label, help text, required indicator, etc.

::component-example
---
name: 'input-time-form-field-example'
---
::

## API

### Props

:component-props

### Slots

:component-slots

### Emits

:component-emits

## Theme

:component-theme

## Changelog

:component-changelog
Binary file added docs/public/components/dark/input-time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/public/components/light/input-time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions playgrounds/nuxt/app/composables/useNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const components = [
'input-menu',
'input-number',
'input-tags',
'input-time',
'input',
'kbd',
'link',
Expand Down
38 changes: 38 additions & 0 deletions playgrounds/nuxt/app/pages/components/input-time.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<script setup lang="ts">
import { Time } from '@internationalized/date'
import theme from '#build/ui/input-time'

const colors = Object.keys(theme.variants.color)
const sizes = Object.keys(theme.variants.size)
const variants = Object.keys(theme.variants.variant)

const attrs = reactive({
color: [theme.defaultVariants.color],
size: [theme.defaultVariants.size],
variant: [theme.defaultVariants.variant]
})

const value = shallowRef(new Time(12, 30))
</script>

<template>
<Navbar>
<USelect v-model="attrs.color" :items="colors" multiple />
<USelect v-model="attrs.variant" :items="variants" multiple />
<USelect v-model="attrs.size" :items="sizes" multiple />
</Navbar>

<Matrix v-slot="props" :attrs="attrs">
<UInputTime v-model="value" autofocus v-bind="props" />
<UInputTime :default-value="new Time(12, 30)" v-bind="props" />
<UInputTime highlight v-bind="props" />
<UInputTime disabled v-bind="props" />
<UInputTime required v-bind="props" />
<UInputTime icon="i-lucide-clock" v-bind="props" />
<UInputTime icon="i-lucide-clock" trailing v-bind="props" />
<UInputTime :avatar="{ src: 'https://github.com/benjamincanac.png' }" icon="i-lucide-clock" trailing v-bind="props" />
<UInputTime loading v-bind="props" />
<UInputTime loading trailing v-bind="props" />
<UInputTime loading icon="i-lucide-clock" trailing-icon="i-lucide-chevron-down" v-bind="props" />
</Matrix>
</template>
Loading
Loading