Home / Function/ DatePickerWithRange() — ui Function Reference

DatePickerWithRange() — ui Function Reference

Architecture documentation for the DatePickerWithRange() function in calendar-example.tsx from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  e564f3f2_c27b_5c6e_9b47_e45a046a9c74["DatePickerWithRange()"]
  56746db4_bde3_b797_f7fa_14d8b5e6af22["calendar-example.tsx"]
  e564f3f2_c27b_5c6e_9b47_e45a046a9c74 -->|defined in| 56746db4_bde3_b797_f7fa_14d8b5e6af22
  style e564f3f2_c27b_5c6e_9b47_e45a046a9c74 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/v4/registry/bases/base/examples/calendar-example.tsx lines 411–465

function DatePickerWithRange() {
  const [date, setDate] = React.useState<DateRange | undefined>({
    from: new Date(new Date().getFullYear(), 0, 20),
    to: addDays(new Date(new Date().getFullYear(), 0, 20), 20),
  })

  return (
    <Example title="Date Picker Range">
      <Field className="mx-auto w-72">
        <FieldLabel htmlFor="date-picker-range">Date Picker Range</FieldLabel>
        <Popover>
          <PopoverTrigger
            render={
              <Button
                variant="outline"
                id="date-picker-range"
                className="justify-start px-2.5 font-normal"
              />
            }
          >
            <IconPlaceholder
              lucide="CalendarIcon"
              tabler="IconCalendar"
              hugeicons="CalendarIcon"
              phosphor="CalendarBlankIcon"
              remixicon="RiCalendarLine"
              data-icon="inline-start"
            />
            {date?.from ? (
              date.to ? (
                <>
                  {format(date.from, "LLL dd, y")} -{" "}
                  {format(date.to, "LLL dd, y")}
                </>
              ) : (
                format(date.from, "LLL dd, y")
              )
            ) : (
              <span>Pick a date</span>
            )}
          </PopoverTrigger>
          <PopoverContent className="w-auto p-0" align="start">
            <Calendar
              mode="range"
              defaultMonth={date?.from}
              selected={date}
              onSelect={setDate}
              numberOfMonths={2}
            />
          </PopoverContent>
        </Popover>
      </Field>
    </Example>
  )
}

Subdomains

Frequently Asked Questions

What does DatePickerWithRange() do?
DatePickerWithRange() is a function in the ui codebase, defined in apps/v4/registry/bases/base/examples/calendar-example.tsx.
Where is DatePickerWithRange() defined?
DatePickerWithRange() is defined in apps/v4/registry/bases/base/examples/calendar-example.tsx at line 411.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free