mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-25 21:56:08 +00:00
* feat: add base and radix docs * feat: transform code for display * fix * fix * fix * fix * fix * chore: remove claude files * fix * fix * fix * chore: run format:write * fix * feat: add more examples * fix * feat: add aspect-ratio * feat: add avatar * feat: add badge * feat: add breadcrumb * fix * feat: add button * fix * fix * fix * feat: add calendar and card * feat: add carousel * fix: chart * feat: add checkbox * feat: add collapsible * feat: add combobox * feat: add command * feat: add context menu * feat: add data-table dialog and drawer * feat: dropdown-menu * feat: add date-picker * feat: add empty * feat: add field and hover-card * fix: input * feat: add input * feat: add input-group * feat: add input-otp * feat: add item * feat: add kbd and label * feat: add menubar * feat: add native-select * feat: add more components * feat: more components * feat: more components * feat: add skeleton, slider and sonner * feat: add spinner and switch * feat: add more components * fix: tabs * fix: tabs * feat: add docs for sidebar * fix * fix * fi * docs: update * fix: create page * fix * fix * chore: add changelog * fix
62 lines
1.7 KiB
TypeScript
62 lines
1.7 KiB
TypeScript
"use client"
|
|
|
|
import * as React from "react"
|
|
import { Button } from "@/examples/base/ui/button"
|
|
import { Calendar } from "@/examples/base/ui/calendar"
|
|
import { Field, FieldLabel } from "@/examples/base/ui/field"
|
|
import {
|
|
Popover,
|
|
PopoverContent,
|
|
PopoverTrigger,
|
|
} from "@/examples/base/ui/popover"
|
|
import { addDays, format } from "date-fns"
|
|
import { CalendarIcon } from "lucide-react"
|
|
import { type DateRange } from "react-day-picker"
|
|
|
|
export 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 (
|
|
<Field className="mx-auto w-60">
|
|
<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"
|
|
/>
|
|
}
|
|
>
|
|
<CalendarIcon 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>
|
|
)
|
|
}
|