snapshot of https://github.com/shadcn-ui/ui.git (main, 2026-09-15; blobs > 131072B omitted)
This commit is contained in:
35
apps/v4/examples/aria/date-picker-demo.tsx
Normal file
35
apps/v4/examples/aria/date-picker-demo.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { getLocalTimeZone, type CalendarDate } from "@internationalized/date"
|
||||
import { ChevronDownIcon } from "lucide-react"
|
||||
|
||||
import { Button } from "@/styles/aria-nova/ui/button"
|
||||
import { Calendar } from "@/styles/aria-nova/ui/calendar"
|
||||
import { Popover, PopoverTrigger } from "@/styles/aria-nova/ui/popover"
|
||||
|
||||
export function DatePickerDemo() {
|
||||
const [date, setDate] = React.useState<CalendarDate | null>(null)
|
||||
|
||||
return (
|
||||
<PopoverTrigger>
|
||||
<Button
|
||||
variant={"outline"}
|
||||
data-empty={!date}
|
||||
className="w-[212px] justify-between text-left font-normal data-[empty=true]:text-muted-foreground"
|
||||
>
|
||||
{date ? (
|
||||
date
|
||||
.toDate(getLocalTimeZone())
|
||||
.toLocaleDateString(undefined, { dateStyle: "long" })
|
||||
) : (
|
||||
<span>Pick a date</span>
|
||||
)}
|
||||
<ChevronDownIcon data-icon="inline-end" />
|
||||
</Button>
|
||||
<Popover className="w-auto p-0" placement="bottom start">
|
||||
<Calendar value={date} onChange={setDate} />
|
||||
</Popover>
|
||||
</PopoverTrigger>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user