Shadcn Datetime Picker: The Ultimate React Component for Date and Time Selection
Shadcn Datetime Picker is a powerful and fully customizable component that simplifies date and time selection in React applications built with the Shadcn UI framework. With advanced features designed to improve user experience, this datetime picker offers seamless integration and a responsive, user-friendly interface. Whether you need a robust datetime, date, or time picker, Shadcn Datetime Picker provides the flexibility and functionality needed for modern applications.
Key Features:
This component is designed to be lightweight, responsive, and highly customizable, making it a must-have for any project using Shadcn UI. Improve the user experience of your React apps with a reliable and flexible datetime picker solution.
Demo: https://shadcn-datetime-picker-pro.vercel.app/
https://github.com/user-attachments/assets/1a14076d-cff7-4068-af10-d61a2ff9284b
To install the Shadcn Datetime Picker, follow these steps:
Install Shadcn dependencies
npx shadcn@latest add button dropdown-menu input label popover select scroll-area
Install react-day-picker
yarn add react-day-picker@^9
Copy and paste below codes into your project.
import { DateTimePicker } from '@/components/datetime-picker';
export default function Home() {
const [date, setDate] = useState<Date | undefined>(undefined);
return <DateTimePicker value={date} onChange={setDate} />;
}
import { DateTimePicker } from '@/components/datetime-picker';
export default function Home() {
const [date, setDate] = useState<Date | undefined>(undefined);
return <DateTimePicker value={date} onChange={setDate} timezone="UTC" />;
}
import { DateTimePicker } from '@/components/datetime-picker';
export default function Home() {
const [date, setDate] = useState<Date | undefined>(undefined);
return (
<DateTimePicker
value={date}
onChange={setDate}
renderTrigger={(value, timezone) => <Button>{value?.toLocaleString()}</Button>}
/>
);
}
import { DateTimePicker } from '@/components/datetime-picker';
export default function Home() {
const [date, setDate] = useState<Date | undefined>(undefined);
const minDate = useMemo(() => subHours(new Date(), 2), []);
const maxDate = useMemo(() => addMonths(new Date(), 2), []);
return <DateTimePicker value={date} onChange={setDate} min={minDate} max={maxDate} />;
}
We welcome contributions! Please feel free to submit a pull request or open an issue for any suggestions or improvements.