snapshot of https://github.com/shadcn-ui/ui.git (main, 2026-09-15; blobs > 131072B omitted)
This commit is contained in:
44
apps/v4/examples/aria/date-picker-dob.tsx
Normal file
44
apps/v4/examples/aria/date-picker-dob.tsx
Normal file
@@ -0,0 +1,44 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { getLocalTimeZone, type CalendarDate } from "@internationalized/date"
|
||||
|
||||
import { Button } from "@/styles/aria-nova/ui/button"
|
||||
import { Calendar } from "@/styles/aria-nova/ui/calendar"
|
||||
import { Field, FieldLabel } from "@/styles/aria-nova/ui/field"
|
||||
import { Popover, PopoverTrigger } from "@/styles/aria-nova/ui/popover"
|
||||
|
||||
export function DatePickerSimple() {
|
||||
const [open, setOpen] = React.useState(false)
|
||||
const [date, setDate] = React.useState<CalendarDate | null>(null)
|
||||
|
||||
return (
|
||||
<Field className="mx-auto w-44">
|
||||
<FieldLabel htmlFor="date">Date of birth</FieldLabel>
|
||||
<PopoverTrigger isOpen={open} onOpenChange={setOpen}>
|
||||
<Button
|
||||
variant="outline"
|
||||
id="date"
|
||||
className="justify-start font-normal"
|
||||
>
|
||||
{date
|
||||
? date.toDate(getLocalTimeZone()).toLocaleDateString()
|
||||
: "Select date"}
|
||||
</Button>
|
||||
<Popover
|
||||
className="w-auto overflow-hidden p-0"
|
||||
placement="bottom start"
|
||||
>
|
||||
<Calendar
|
||||
value={date}
|
||||
captionLayout="dropdown"
|
||||
onChange={(date) => {
|
||||
setDate(date)
|
||||
setOpen(false)
|
||||
}}
|
||||
/>
|
||||
</Popover>
|
||||
</PopoverTrigger>
|
||||
</Field>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user