ComponentsCore
Date Picker
A compound component built on top of a date field and calendar popover, providing accessible date selection through typing or visual interaction.
Example
Features
A date picker can be built using <input type="date">, but this is very limited in functionality, lacking in internationalization capabilities, inconsistent between browsers, and difficult to style. DatePicker helps achieve accessible and international date and time pickers that can be styled as needed.
Dates and times– Support for dates and times with configurable granularity.International– Support for 13 calendar systems used around the world, including Gregorian, Buddhist, Islamic, Persian, and more. Locale-specific formatting, number systems, hour cycles, and right-to-left support are available as well.Time zone aware– Dates and times can optionally include a time zone. All modifications follow time zone rules such as daylight saving time.Accessible– Each date and time unit is displayed as an individually focusable and editable segment, which allows users an easy way to edit dates using the keyboard, in any date format and locale. Users can also open a calendar popover to select dates in a standard month grid. Localized screen reader messages are included to announce when the selection and visible date range change.Touch friendly– Date segments are editable using an easy to use numeric keypad, and all interactions are accessible using touch-based screen readers.Validation– Integrates with HTML forms, supporting required, minimum and maximum values, unavailable dates, custom validation functions, realtime validation, and server-side validation errors.Customizable– As with all of React Aria, the DOM structure and styling of all elements can be fully customized.
Installation
Required Component
This component depends on Calendar, Date Field, Field and Popover. Make sure you have installed and configured it before using this component.Calendar
A calendar component presents one or more grids of dates, enabling users to view and interact with a range of days. It allows for the selection of a single specific date within the displayed time period.
Date Field
An input field designed specifically for entering and choosing dates, with support for multiple date formats and built-in validation.
Field
The Field component is fundamental and used by many other components. It applies consistent, reusable styles and appears in inputs, labels, descriptions, and other related elements.
Popover
A popover is a floating overlay element that appears next to a trigger element, providing additional contextual information or actions without navigating away from the current page.
Install following dependencies:
npm install react-aria-components tw-animate-css tailwindcss-react-aria-components class-variance-authority lucide-react clsx tailwind-merge motionAdd cn helper using clsx and twMerge for conditional class merging in Tailwind components.
TypeScript
JavaScript
Copy and paste the following code into your project.
TypeScript
JavaScript
npx @libravelui@latest add date-pickerAnatomy
import {
DatePicker,
DatePickerTrigger,
} from "@/components/ui/core/date-picker";<DatePicker>
<DatePickerTrigger />
</DatePicker>Another Example
Date Time Picker
A simple and accessible way to select an exact date and time.
Props
Loading types…