# Date input (UI SDK): Min and max

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

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

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

## Add this example

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

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

## Source

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

import * as React from "react"

import { Label } from "@/components/ui/label"
import { DateInput } from "@/components/ui/ui-sdk-date-input"

const min = "2026-01-01"
const max = "2026-12-31"

function UiSdkDateInputMinMax() {
  const [date, setDate] = React.useState<string | null>("2026-06-15")
  const outside = date !== null && (date < min || date > max)

  return (
    <div className="flex w-full max-w-44 flex-col gap-2">
      <Label id="check-in">Check-in</Label>
      <DateInput
        aria-labelledby="check-in"
        aria-describedby="check-in-message"
        min={min}
        max={max}
        defaultValue="2026-06-15"
        onValueChange={(value) => setDate(value)}
      />
      <p
        id="check-in-message"
        className={
          outside
            ? "m-0 text-xs text-destructive"
            : "m-0 text-xs text-muted-foreground"
        }
      >
        {outside ? "Pick a day in 2026." : "Any day in 2026."}
      </p>
    </div>
  )
}

export { UiSdkDateInputMinMax }
```

## Props in this example

### DateInput

| 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. |
| `min` | `string` | – |  |
| `max` | `string` | – |  |

## More Date input examples

- [Date and time](https://hextaui.com/docs/ui-sdk-date-input/examples/date-time)
- [Unavailable dates](https://hextaui.com/docs/ui-sdk-date-input/examples/unavailable)
- [Locale](https://hextaui.com/docs/ui-sdk-date-input/examples/locale)
- [Form](https://hextaui.com/docs/ui-sdk-date-input/examples/form)
- [Controller](https://hextaui.com/docs/ui-sdk-date-input/examples/controller)
- [Disabled](https://hextaui.com/docs/ui-sdk-date-input/examples/disabled)
- [Read-only](https://hextaui.com/docs/ui-sdk-date-input/examples/read-only)
- [Right to left](https://hextaui.com/docs/ui-sdk-date-input/examples/rtl)
