DatePicker
Overviewimport { CalendarSystem, DatePicker, DatePickerFooter, DatePreset, DateRange, DateRangePicker } from '@nili/ui';This is the library’s own overview page, rendered live. Switch the language or the theme in the header and it follows.
Basic
Uncontrolled with defaultValue, or controlled with value plus onChange. The calendar defaults to Jalali under a Persian locale and Gregorian otherwise — you rarely have to say which.
import { DatePicker } from "@nili/ui"
export function Example() {
const [date, setDate] = useState<Date | null>(new Date())
return <DatePicker value={date} onChange={setDate} />
}Calendar systems
calendar forces Jalali (Solar Hijri) or Gregorian; locale drives month names, weekday names and numerals. allowCalendarSwitch puts a toggle in the header so the user can change it themselves.
import { DatePicker } from "@nili/ui"
export function Example() {
return (
<>
<DatePicker calendar="jalali" locale="fa" />
<DatePicker calendar="gregorian" locale="en" />
{/* let the user pick */}
<DatePicker
allowCalendarSwitch
labels={{ calendarSwitch: "Change calendar", jalali: "شمسی", gregorian: "میلادی" }}
/>
</>
)
}Bounds, disabled days and markers
minDate and maxDate clamp the range; isDateDisabled handles the rest — weekends, holidays, days a room is already booked. markedDates gets Figma's marker dot.
import { DatePicker } from "@nili/ui"
export function Example() {
return (
<DatePicker
minDate={new Date()}
maxDate={addDays(60)}
markedDates={[addDays(3), addDays(10)]}
isDateDisabled={(date) => date.getDay() === 5}
/>
)
}Footer
footer is a free slot; DatePickerFooter is the Figma row that usually goes in it. Use it when the picker sits in a popover and the selection should only apply on Apply.
import { DatePicker, DatePickerFooter, Button } from "@nili/ui"
export function Example() {
return (
<DatePicker
footer={
<DatePickerFooter>
<Button appearance="stroke" size="xs">Cancel</Button>
<Button size="xs">Apply</Button>
</DatePickerFooter>
}
/>
)
}Date Range Picker
Two dates instead of one. presets is Figma's Period Range — the shortcut column. Every range is { from, to }, and either end may be null while the user is mid-selection.
import { DateRangePicker } from "@nili/ui"
export function Example() {
const [range, setRange] = useState({ from: new Date(), to: null })
return (
<DateRangePicker
value={range}
onChange={setRange}
presets={[
{ label: "Last 7 days", range: () => ({ from: addDays(-7), to: new Date() }) },
{ label: "Last 30 days", range: () => ({ from: addDays(-30), to: new Date() }) },
{ label: "This month", range: () => ({ from: startOfMonth(), to: new Date() }) },
]}
/>
)
}CalendarBase
internalOther props
| Prop | Type | Default | Notes |
|---|---|---|---|
| calendar | jalali | gregorian | — | `'jalali'` (Solar Hijri — Shamsi, also called Jalali) or `'gregorian'`. Defaults to Jalali under a Persian locale and Gregorian otherwise. |
| locale | string | — | BCP-47 tag for month names, weekday names and numerals. |
| allowCalendarSwitch | boolean | — | Let the user switch calendars from a toggle in the header. |
| minDate | Date | — | |
| maxDate | Date | — | |
| markedDates | Date[] | — | Days that get a marker dot — Figma's "Marked" state. |
| isDateDisabled | (date: Date) => boolean | — | |
| labels | { previousMonth?: string; nextMonth?: string; calendarSwitch?: string; jalali?: string; gregorian?: string; } | — |
CalendarGrid
internalOther props
| Prop | Type | Default | Notes |
|---|---|---|---|
| calendar* | jalali | gregorian | — | |
| locale* | string | — | |
| cursor* | { year: number; month: number } | — | |
| isSelected* | (date: Date) => boolean | — | |
| isInRange | (date: Date) => boolean | — | |
| rangeEdge | (date: Date) => 'start' | 'end' | 'both' | 'none' | — | |
| isDisabled* | (date: Date) => boolean | — | |
| isMarked* | (date: Date) => boolean | — | |
| onSelect* | (date: Date) => void | — | |
| onHover | (date: Date | null) => void | — |
CalendarToggle
internalDatePicker
extends CalendarBaseProps, Omit<ComponentPropsWithoutRef<'div'>, 'onChange' | 'defaultValue'>
Other props
| Prop | Type | Default | Notes |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| footer | ReactNode | — | Figma footer — typically `<DatePickerFooter>` with Cancel / Apply. |
| value | Date | null | — | |
| defaultValue | Date | null | — | |
| onChange | (date: Date | null) => void | — | |
| calendar | jalali | gregorian | — | `'jalali'` (Solar Hijri — Shamsi, also called Jalali) or `'gregorian'`. Defaults to Jalali under a Persian locale and Gregorian otherwise. |
| locale | string | en | BCP-47 tag for month names, weekday names and numerals. |
| allowCalendarSwitch | boolean | false | Let the user switch calendars from a toggle in the header. |
| minDate | Date | — | |
| maxDate | Date | — | |
| markedDates | Date[] | — | Days that get a marker dot — Figma's "Marked" state. |
| isDateDisabled | (date: Date) => boolean | — | |
| labels | { previousMonth?: string; nextMonth?: string; calendarSwitch?: string; jalali?: string; gregorian?: string; } | — |
DatePickerFooter
DateRangePicker
extends CalendarBaseProps, Omit<ComponentPropsWithoutRef<'div'>, 'onChange' | 'defaultValue'>
Other props
| Prop | Type | Default | Notes |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| value | DateRange | — | |
| defaultValue | DateRange | — | |
| onChange | (range: DateRange) => void | — | |
| presets | DatePreset[] | — | Shortcut column — Figma's "Period Range". |
| footer | ReactNode | — | |
| calendar | jalali | gregorian | — | `'jalali'` (Solar Hijri — Shamsi, also called Jalali) or `'gregorian'`. Defaults to Jalali under a Persian locale and Gregorian otherwise. |
| locale | string | en | BCP-47 tag for month names, weekday names and numerals. |
| allowCalendarSwitch | boolean | false | Let the user switch calendars from a toggle in the header. |
| minDate | Date | — | |
| maxDate | Date | — | |
| markedDates | Date[] | — | Days that get a marker dot — Figma's "Marked" state. |
| isDateDisabled | (date: Date) => boolean | — | |
| labels | { previousMonth?: string; nextMonth?: string; calendarSwitch?: string; jalali?: string; gregorian?: string; } | — |
DateSelector
internalDayCell
internalVariant axes — from the component’s cva definition
| Prop | Type | Default | Notes |
|---|---|---|---|
| outside | 'true' | 'false' | false | |
| selected | 'true' | 'false' | false | |
| inRange | 'true' | 'false' | false | |
| rangeEdge | start | end | both | none | none | |
| today | 'true' | 'false' | false | |
| marked | 'true' | 'false' | false |
DayLabel
internalHeader
internalOther props
| Prop | Type | Default | Notes |
|---|---|---|---|
| calendar* | jalali | gregorian | — | |
| locale* | string | — | |
| cursor* | { year: number; month: number } | — | |
| onStep* | (delta: number) => void | — | |
| allowCalendarSwitch* | boolean | — | |
| onCalendarChange* | (system: CalendarSystem) => void | — | |
| labels* | NonNullable<DatePickerProps['labels']> | — |
PeriodRange
internalPeriodRangeItem
internalVariant axes — from the component’s cva definition
| Prop | Type | Default | Notes |
|---|---|---|---|
| selected | 'true' | 'false' | false |