# Time input (UI SDK): Min and max

> A time before `min` or after `max` marks the field invalid, and its form won’t submit.

Canonical: https://hextaui.com/docs/ui-sdk-time-input/examples/min-max

Component docs: https://hextaui.com/docs/ui-sdk-time-input

## Add this example

```bash
npx shadcn@latest add https://hextaui.com/r/ui-sdk-time-input-min-max.json
```

This adds `components/examples/ui-sdk-time-input/min-max.tsx` with the Time input component and the HextaUI theme tokens.

## Source

```tsx title="components/examples/ui-sdk-time-input/min-max.tsx"
"use client"

import * as React from "react"

import { Label } from "@/components/ui/label"
import { TimeInput } from "@/components/ui/ui-sdk-time-input"

const opens = "09:00"
const closes = "17:30"

function UiSdkTimeInputMinMax() {
  const [time, setTime] = React.useState<string | null>("16:00")
  const outside = time !== null && (time < opens || time > closes)

  return (
    <div className="flex w-full max-w-40 flex-col gap-2">
      <Label id="pickup-time">Pickup</Label>
      <TimeInput
        aria-labelledby="pickup-time"
        aria-describedby="pickup-time-message"
        defaultValue="16:00"
        min={opens}
        max={closes}
        hourCycle={24}
        onValueChange={(value) => setTime(value)}
      />
      <p
        id="pickup-time-message"
        className={
          outside
            ? "m-0 text-xs text-destructive"
            : "m-0 text-xs text-muted-foreground"
        }
      >
        {outside ? "We’re closed then." : "Open 09:00 to 17:30."}
      </p>
    </div>
  )
}

export { UiSdkTimeInputMinMax }
```

## Props in this example

### TimeInput

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `defaultValue` | `string \| null` | – |  |
| `onValueChange` | `(value: string \| null, details) => void` | – | Runs once every part holds something, and with null when one is emptied. |
| `hourCycle` | `12 \| 24` | – | Defaults to the locale’s clock. |
| `min` | `string` | – |  |
| `max` | `string` | – |  |

## More Time input examples

- [Clock and seconds](https://hextaui.com/docs/ui-sdk-time-input/examples/clock)
- [Invalid](https://hextaui.com/docs/ui-sdk-time-input/examples/range)
- [Locale](https://hextaui.com/docs/ui-sdk-time-input/examples/locale)
- [Form](https://hextaui.com/docs/ui-sdk-time-input/examples/form)
- [Controller](https://hextaui.com/docs/ui-sdk-time-input/examples/controller)
- [Disabled](https://hextaui.com/docs/ui-sdk-time-input/examples/disabled)
- [Read-only](https://hextaui.com/docs/ui-sdk-time-input/examples/read-only)
- [Right to left](https://hextaui.com/docs/ui-sdk-time-input/examples/rtl)
