snapshot of https://github.com/shadcn-ui/ui.git (main, 2026-09-15; blobs > 131072B omitted)
This commit is contained in:
37
apps/v4/examples/aria/date-picker-basic.tsx
Normal file
37
apps/v4/examples/aria/date-picker-basic.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
"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 [date, setDate] = React.useState<CalendarDate | null>(null)
|
||||
|
||||
return (
|
||||
<Field className="mx-auto w-44">
|
||||
<FieldLabel htmlFor="date-picker-simple">Date</FieldLabel>
|
||||
<PopoverTrigger>
|
||||
<Button
|
||||
variant="outline"
|
||||
id="date-picker-simple"
|
||||
className="justify-start font-normal"
|
||||
>
|
||||
{date ? (
|
||||
date
|
||||
.toDate(getLocalTimeZone())
|
||||
.toLocaleDateString(undefined, { dateStyle: "long" })
|
||||
) : (
|
||||
<span>Pick a date</span>
|
||||
)}
|
||||
</Button>
|
||||
<Popover className="w-auto p-0" placement="bottom start">
|
||||
<Calendar value={date} onChange={setDate} />
|
||||
</Popover>
|
||||
</PopoverTrigger>
|
||||
</Field>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user