Single date
Choose one weekday date from a labelled trigger with an associated hint. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.
"use client"
import * as React from "react"
import { DatePicker } from "@/components/ui/date-picker"
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field"
const exampleMonth = new Date(2026, 9, 1)
export function DatePickerSingleDate() {
const id = React.useId()
const [date, setDate] = React.useState<Date | undefined>()
return (
<div className="flex w-full max-w-sm flex-col gap-6">
<Field>
<FieldLabel id={`${id}-date-label`} htmlFor={`${id}-date`}>
Appointment date
</FieldLabel>
<DatePicker
id={`${id}-date`}
aria-labelledby={`${id}-date-label`}
aria-describedby={`${id}-date-hint`}
value={date}
onValueChange={setDate}
disabledDates={{ dayOfWeek: [0, 6] }}
defaultMonth={exampleMonth}
/>
<FieldDescription id={`${id}-date-hint`}>Appointments are available on weekdays.</FieldDescription>
</Field>
</div>
)
}