radkradk

Date Picker

A date picker combining calendar, popover, and button.

Installation

npx radk-cli@latest add date-picker

Usage

import { DatePicker } from "@/components/ui/date-picker"
const [date, setDate] = React.useState<Date | undefined>()

<DatePicker date={date} onDateChange={setDate} placeholder="Pick a date" />

Props

PropTypeDescription
dateDate | undefinedThe selected date (controlled)
onDateChange(date: Date | undefined) => voidCalled when a date is selected
placeholderstringText shown when no date is selected
classNamestringAdditional classes for the trigger button

Examples

With Form

Combine with the Form component and react-hook-form:

<FormField
  control={form.control}
  name="date"
  render={({ field }) => (
    <FormItem>
      <FormLabel>Date</FormLabel>
      <FormControl>
        <DatePicker date={field.value} onDateChange={field.onChange} />
      </FormControl>
      <FormMessage />
    </FormItem>
  )}
/>