Date Picker
iconiq-ui/date-pickerFreeComponent
Collapsible date picker trigger with the shared Iconiq Calendar panel, spring open motion, and month-aware selection.
Live preview
live · rendered by the registry
Rendered by Iconiq UI on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.iconiqui.com/r/date-picker.jsonSource
1"use client";23import { Input as InputPrimitive } from "@base-ui/react/input";4import { format, type Locale, startOfMonth } from "date-fns";5import { CalendarIcon, X } from "lucide-react";6import { motion, useReducedMotion } from "motion/react";7import {8 type ForwardedRef,9 forwardRef,10 type MouseEvent,11 type RefObject,12 useCallback,13 useEffect,14 useId,15 useLayoutEffect,16 useRef,17 useState,18} from "react";19import { createPortal } from "react-dom";2021import { Calendar, type CalendarProps } from "@/components/ui/calendar";22import { cn } from "@/lib/utils";2324const datePickerTriggerCornerClassName =25 "rounded-lg supports-[corner-shape:squircle]:corner-squircle supports-[corner-shape:squircle]:rounded-[11px]";2627const datePickerInputShellClassName = cn(28 "group flex w-full items-center border border-border bg-card text-left text-foreground text-sm transition-[border-color,box-shadow] focus-within:border-foreground/30 hover:border-foreground/30",29 "[&:has(input:disabled)]:cursor-not-allowed [&:has(input:disabled)]:opacity-50",30 "[&:has(input[aria-invalid=true])]:border-destructive"31);3233const datePickerInputClassName = cn(34 "min-w-0 flex-1 cursor-pointer truncate bg-transparent py-0 text-left font-medium tracking-tight outline-none focus-visible:outline-none",35 "text-foreground placeholder:text-muted-foreground",36 "[-webkit-tap-highlight-color:transparent]"37);3839export const DATE_PICKER_PANEL_WIDTH = {40 sm: 212,41 md: 240,42 lg: 282,43} as const;4445export type DatePickerAlign = "start" | "end";46export type DatePickerSide = "top" | "bottom";4748export const DEFAULT_DATE_PICKER_FORMAT = "EEE, MMM d, yyyy";49export const DEFAULT_DATE_PICKER_ARIA_FORMAT = "PPPP";50const DATE_PICKER_FORM_VALUE_FORMAT = "yyyy-MM-dd";5152const PANEL_GAP_PX = 12;53const VIEWPORT_PADDING_PX = 8;54const FOCUSABLE_SELECTOR =55 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';5657export function getDatePickerPanelWidth(58 size: NonNullable<CalendarProps["size"]> = "md"59): number {60 return DATE_PICKER_PANEL_WIDTH[size];61}6263export function resolveDatePickerViewMonth(64 value: Date | null | undefined,65 selected: Date | null | undefined,66 fallback: Date = new Date()67): Date {68 const source = value !== undefined ? value : selected;69 return startOfMonth(source ?? fallback);70}7172export function formatDatePickerLabel(73 date: Date,74 dateFormat: string,75 locale?: Locale76): string {77// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from Iconiq UI
All 119 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | Iconiq UI | Components | Free | 2 deps | |
| AI Inputai-input | Iconiq UI | Components | Free | 3 deps | |
| Alertalert | Iconiq UI | Components | Free | 2 deps | |
| Avataravatar | Iconiq UI | Components | Free | 3 deps | |
| Accordion (Base UI)b-accordion | Iconiq UI | Components | Free | 2 deps | |
| Alert Dialog (Base UI)b-alert-dialog | Iconiq UI | Components | Free | 3 deps | |
| Autocomplete (Base UI)b-autocomplete | Iconiq UI | Components | Free | 3 deps | |
| Avatar (Base UI)b-avatar | Iconiq UI | Components | Free | 2 deps |
