DateRangePicker
neon-ui/date-range-pickerFreeComponent
Custom date range picker: mono pill trigger, preset rail, hand-built month grid with range wash.
Install it
npx shadcn@latest add https://ui.neon.com/r/date-range-picker.jsonSource
1"use client";23import type { ComponentProps } from "react";4import { useState } from "react";56import {7 Popover,8 PopoverContent,9 PopoverTrigger,10} from "@/components/ui/popover";11import { cn } from "@/lib/utils";1213export interface DateRange {14 from: Date;15 to: Date;16}1718export interface DateRangePreset {19 label: string;20 /** Days back from today, inclusive. */21 days: number;22}2324export type DateRangePickerProps = Omit<25 ComponentProps<"button">,26 "value" | "onChange"27> & {28 value: DateRange;29 onValueChange: (range: DateRange) => void;30 /** Quick ranges in the popup rail. */31 presets?: DateRangePreset[];32 /** Days after today stay unselectable. */33 disableFuture?: boolean;34};3536/* ─────────────────────────────────────────────────────────37 * PICKER STORYBOARD38 *39 * trigger a mono pill reading the range ("Jul 1 – Jul40 * 18"); hover warms the hairline41 * open the panel rises 4px: preset rail on the42 * left, one month grid on the right43 * pick first click plants the start (square primary44 * marker); the tentative range washes45 * primary/10 under the pointer as it moves;46 * the second click lands the end and closes47 * presets one click, done — the rail is the fast path48 * today wears a hairline ring, never color49 * motion the month swaps with a 150ms crossfade;50 * everything static under reduced motion51 * ───────────────────────────────────────────────────────── */52const WEEKDAYS = ["mo", "tu", "we", "th", "fr", "sa", "su"] as const;5354const MONTH_LABEL = new Intl.DateTimeFormat("en-US", {55 month: "long",56 year: "numeric",57});5859const RANGE_LABEL = new Intl.DateTimeFormat("en-US", {60 day: "numeric",61 month: "short",62});6364const DEFAULT_PRESETS: DateRangePreset[] = [65 { days: 7, label: "last 7 days" },66 { days: 14, label: "last 14 days" },67 { days: 30, label: "last 30 days" },68];6970const startOfDay = (date: Date) =>71 new Date(date.getFullYear(), date.getMonth(), date.getDate());7273const sameDay = (a: Date, b: Date) =>74 a.getFullYear() === b.getFullYear() &&75 a.getMonth() === b.getMonth() &&76 a.getDate() === b.getDate();7778const formatRange = (range: DateRange) =>79// … truncated
What it pulls in
Other registry items
Files it writes
More from neon-ui
All 77 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| ActivityFeedactivity-feed | neon-ui | Components | Free | 2 deps | |
| AgentChatagent-chat | neon-ui | Components | Free | 6 deps | |
| AnimatedWashanimated-wash | neon-ui | Components | Free | no deps · 2 files | |
| ApiKeyListapi-key-list | neon-ui | Components | Free | 2 deps | |
| AppCardapp-card | neon-ui | Components | Free | 2 deps | |
| AppCreatorapp-creator | neon-ui | Components | Free | 2 deps | |
| AuthFormauth-form | neon-ui | Components | Free | no deps | |
| AutoscaleChartautoscale-chart | neon-ui | Components | Free | 1 dep |
