Chalk UI
Getting started
Customization
Dark Mode
CLI
Components
Accordion
Address Input
Alert
App Layout
Autocomplete
Avatar
Badge
Breadcrumbs
Button
Calendar
Card
Carousel
Chart (Area)
Chart (Bar)
Chart (Donut)
Chart (Line)
Checkbox
Checkbox Group
Collapsible
Combobox
Command
Currency Input
DataGrid
Date Picker
Date Range Picker
Disclosure
Drawer
Dropdown Menu
Form
Horizontal Draggable Scroll
Hover Card
Loading Spinner
Loading Overlay
Modal
Native Select
Navigation Menu
Number Input
Page Header
Pagination
Phone Input
Popover
Progress Bar
Radio Group
Scroll Area
Select
Separator
Simple Dropzone
Skeleton
Static Tabs
Stats
Switch
Table
Tabs
Text Input
Textarea
Timeline
Toaster
Tooltip
Vertical Menu

Date Picker

A select component for picking dates.

SourceDependency API

Installation

npx @rahimstack@latest add date-picker

Usage

Locale

The locale is set to en-US by default. To change it, you can use the locale prop.

import { DatePicker } from "@/workshop/date-picker"
import * as React from "react"
import { fr } from "date-fns/locale"
 
export default function DatePickerDemo() {
    const [value, setValue] = React.useState<Date | undefined>(new Date())
 
    return (
        <DatePicker
            value={value}
            onValueChange={setValue}
            locale={fr}
        />
    )
}

Options

You can use the pickerOptions prop to set rules for the date picker. These options are passed to the calendar component. You can read more about the options here.

Example
<DatePicker
    {...props}
    pickerOptions={{
        disabled: { before: new Date() } // Disables all dates before today
    }}
/>

Uncontrolled

  • Input type: date, Ref prop: inputRef
  • Value type: date ("yyyy-MM-dd")
  • If not required, an empty string will be submitted if the input is empty.

API Reference

const DatePickerAnatomy = defineStyleAnatomy({
    root: cva([
        "UI-DatePicker__root",
        "line-clamp-1 text-left"
    ]),
    placeholder: cva([
        "UI-DatePicker__placeholder",
        "text-[--muted]",
    ]),
})