

<InteractiveDemo
  name="time-field"
  controls="[
  {
    type: &#x22;string&#x22;,
    name: &#x22;label&#x22;,
    defaultValue: &#x22;Time&#x22;,
  },
  {
    type: &#x22;string&#x22;,
    name: &#x22;description&#x22;,
    defaultValue: &#x22;&#x22;,
    placeholder: &#x22;Helper text&#x22;,
  },
  {
    type: &#x22;enum&#x22;,
    name: &#x22;granularity&#x22;,
    options: [&#x22;hour&#x22;, &#x22;minute&#x22;, &#x22;second&#x22;],
    defaultValue: &#x22;minute&#x22;,
  },
  {
    type: &#x22;enum&#x22;,
    name: &#x22;size&#x22;,
    options: [&#x22;sm&#x22;, &#x22;md&#x22;, &#x22;lg&#x22;],
    defaultValue: &#x22;md&#x22;,
  },
  {
    type: &#x22;boolean&#x22;,
    name: &#x22;isRequired&#x22;,
    defaultValue: false,
  },
  {
    type: &#x22;boolean&#x22;,
    name: &#x22;isDisabled&#x22;,
    defaultValue: false,
  },
  {
    type: &#x22;boolean&#x22;,
    name: &#x22;isReadOnly&#x22;,
    defaultValue: false,
  },
  {
    type: &#x22;boolean&#x22;,
    name: &#x22;isInvalid&#x22;,
    defaultValue: false,
  },
]"
/>

## Installation [#installation]

<InstallPrerequisite>
  Before adding components, init your project with your design system from the [Studio](/studio).
</InstallPrerequisite>

<CodeBlockTabs defaultValue="npm" groupId="package-manager">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="npm">
      npm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="pnpm">
      pnpm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="yarn">
      yarn
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="bun">
      bun
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="npm">
    ```bash
    npx shadcn@latest add @dotui/time-field
    ```
  </CodeBlockTab>

  <CodeBlockTab value="pnpm">
    ```bash
    pnpm dlx shadcn@latest add @dotui/time-field
    ```
  </CodeBlockTab>

  <CodeBlockTab value="yarn">
    ```bash
    yarn dlx shadcn@latest add @dotui/time-field
    ```
  </CodeBlockTab>

  <CodeBlockTab value="bun">
    ```bash
    bunx shadcn@latest add @dotui/time-field
    ```
  </CodeBlockTab>
</CodeBlockTabs>

## Usage [#usage]

```tsx
import { TimeField } from "@/components/ui/time-field"
import { DateInput } from "@/components/ui/input"
import { Label } from "@/components/ui/field"
```

```tsx
<TimeField>
  <Label>Time</Label>
  <DateInput />
</TimeField>
```

## Anatomy [#anatomy]

`TimeField` wraps a `Label`, the `DateInput` that holds the editable time segments, and an optional `Description` or `FieldError`.

```tsx
import { TimeField } from "@/components/ui/time-field"
import { DateInput } from "@/components/ui/input"
import { Label, Description, FieldError } from "@/components/ui/field"
```

```tsx
<TimeField>
  <Label />
  <DateInput />
  <Description />
  <FieldError />
</TimeField>
```

## Value [#value]

Values are `Time` objects from `@internationalized/date`. Use `defaultValue` for uncontrolled state, or `value` with `onChange` to control it. Parse a string with `parseTime`.

```tsx
import { Time } from "@internationalized/date"
```

```tsx
<TimeField defaultValue={new Time(11, 45)}>
  <Label>Time</Label>
  <DateInput />
</TimeField>
```

## Granularity [#granularity]

`granularity` sets the smallest editable segment — `hour`, `minute` (the default), or `second`.

```tsx
<TimeField granularity="second" defaultValue={new Time(11, 45, 22)}>
  <Label>Time</Label>
  <DateInput />
</TimeField>
```

## Hour cycle [#hour-cycle]

`hourCycle` forces 12- or 24-hour display regardless of the locale.

```tsx
<TimeField hourCycle={24} defaultValue={new Time(18, 45)}>
  <Label>Time</Label>
  <DateInput />
</TimeField>
```

## Validation [#validation]

Set `isRequired` or `isInvalid` and render messages with `FieldError`; `minValue` and `maxValue` constrain the allowed time.

```tsx
<TimeField isRequired minValue={new Time(9)} maxValue={new Time(17)}>
  <Label>Meeting time</Label>
  <DateInput />
  <FieldError />
</TimeField>
```

## Examples [#examples]

<Examples className="sm:grid-cols-2 md:grid-cols-2">
  <Example name="time-field/demos/basic" title="Basic Time Field" />

  <Example name="time-field/demos/prefix-and-suffix" title="With Icon" />

  <Example name="time-field/demos/time-zones" title="Time Zones" />
</Examples>

## API Reference [#api-reference]

<Reference name="time-field" />
