HextaUI

Date input (UI SDK): Unavailable dates

unavailable takes ISO dates, { from, to } ranges, weekdays or a function, and a date on one is invalid.

We deliver Monday to Friday.

"use client"

import * as React from "react"

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

function isWeekend(date: string) {
  const day = new Date(`${date}T12:00`).getDay()
  return day === 0 || day === 6
}

function UiSdkDateInputUnavailable() {
  const [date, setDate] = React.useState<string | null>("2026-11-02")
  const weekend = date !== null && isWeekend(date)

  return (
    <div className="flex w-full max-w-44 flex-col gap-2">
      <Label id="delivery-date">Delivery date</Label>
      <DateInput
        aria-labelledby="delivery-date"
        aria-describedby="delivery-date-message"
        defaultValue="2026-11-02"
        unavailable={{ weekday: [0, 6] }}
        onValueChange={(value) => setDate(value)}
      />
      <p
        id="delivery-date-message"
        className={
          weekend
            ? "m-0 text-xs text-destructive"
            : "m-0 text-xs text-muted-foreground"
        }
      >
        {weekend
          ? "We don’t deliver on weekends."
          : "We deliver Monday to Friday."}
      </p>
    </div>
  )
}

export { UiSdkDateInputUnavailable }

This adds the example as components/examples/ui-sdk-date-input/unavailable.tsx, together with the Date input component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/ui-sdk-date-input-unavailable.json

To add only the component, follow the Date input installation.

Props in this example

The Date input props this example sets, from the API reference.

PropTypeDefault
defaultValue
string | null–
onValueChangeRuns once every part holds something, and with null when one is emptied.
(value: string | null, details) => void–
unavailableISO dates, { from, to } ranges, { weekday } or a function.
DateMatchers–

Every prop is in the Date input API reference.

See them all, with keyboard support and accessibility notes, on the Date input page.