Components
npx shadcn@latest add https://21st.dev/r/originui/calendarLoading preview...
"use client";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
import { Calendar } from "@/components/ui/calendar";
import { Label } from "@/components/ui/label";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { format } from "date-fns";
import { CalendarIcon } from "lucide-react";
import { useId, useState } from "react";
function Component() {
const id = useId();
const [date, setDate] = useState<Date | undefined>();
return (
<div>
<div className="space-y-2">
<Label htmlFor={id}>Date picker</Label>
<Popover>
<PopoverTrigger asChild>
<Button
id={id}
variant={"outline"}
className={cn(
"group w-full justify-between bg-background px-3 font-normal outline-offset-0 hover:bg-background focus-visible:border-ring focus-visible:outline-[3px] focus-visible:outline-ring/20",
!date && "text-muted-foreground",
)}
>
<span className={cn("truncate", !date && "text-muted-foreground")}>
{date ? format(date, "PPP") : "Pick a date"}
</span>
<CalendarIcon
size={16}
strokeWidth={2}
className="shrink-0 text-muted-foreground/80 transition-colors group-hover:text-foreground"
aria-hidden="true"
/>
</Button>
</PopoverTrigger>
<PopoverContent className="w-auto p-2" align="start">
<Calendar mode="single" selected={date} onSelect={setDate} />
</PopoverContent>
</Popover>
</div>
<p className="mt-2 text-xs text-muted-foreground" role="region" aria-live="polite">
Built with{" "}
<a
className="underline hover:text-foreground"
href="https://daypicker.dev/"
target="_blank"
rel="noopener nofollow"
>
React DayPicker
</a>
</p>
</div>
);
}
export { Component };
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...