Nasaq
Components

DatePicker

Input-looking trigger that opens a Calendar in a popover to pick a date or a range, plus a segmented TimePicker. Field-aware, locale and RTL aware.

PreviewOpen ↗

Code

import { DatePicker, Field, FieldDescription, FieldLabel } from "@fadymondy/nasaq/web";import { useState } from "react";export function Example() {  const [date, setDate] = useState<Date | null>(null);  return (    <Field>      <FieldLabel>Start date</FieldLabel>      <DatePicker value={date} onValueChange={setDate} min={new Date()} />      <FieldDescription>Work begins on this day.</FieldDescription>    </Field>  );}

Pickers · beta

Live examples and controls: DatePicker in the lab.

Install

npx shadcn@latest add https://docs.nasaqui.com/r/date-picker.json

DatePicker and DateRangePicker are a form control that looks like an Input: a button showing the chosen date, which opens a Calendar in a Popover. TimePicker is an hour / minute (/ AM-PM) group of selects. All three work inside Field (label, description, error, invalid state).

When to use

  • A date, a date range or a time of day in a form.

When not to use

  • Always-visible month grids (scheduling views): use Calendar.
  • Durations or free numbers: use a number Input.

Import

import { DatePicker, DateRangePicker, TimePicker } from "@fadymondy/nasaq/web";

Quick start

import { DatePicker, Field, FieldDescription, FieldLabel } from "@fadymondy/nasaq/web";
import { useState } from "react";

export function Example() {
  const [date, setDate] = useState<Date | null>(null);
  return (
    <Field>
      <FieldLabel>Start date</FieldLabel>
      <DatePicker value={date} onValueChange={setDate} min={new Date()} />
      <FieldDescription>Work begins on this day.</FieldDescription>
    </Field>
  );
}

Anatomy

DatePicker / DateRangePicker
  Popover
    trigger button        data-slot="date-picker-trigger"  (Field.Control)
    PopoverContent > Calendar
TimePicker                data-slot="time-picker"
  select                  data-slot="time-picker-hour" | "time-picker-minute" | "time-picker-period"

API

Shared by DatePicker and DateRangePicker:

PropTypeDefaultDescription
placeholderstringEnglish / ArabicText when empty.
disabledbooleanfalseDisables the control.
min / maxDatenoneEarliest / latest pickable day.
disabledDatesDate[] | (date: Date) => booleannoneDays that cannot be picked.
weekStartsOn0..6from locale0 = Sunday.
locale / dirstring / "ltr" | "rtl"providerOverride the active locale and direction.
calendarstringnoneIntl calendar for labels, e.g. "islamic-umalqura".
formatFormatDateOptions{ dateStyle: "medium" }Trigger text format.
namestringnoneHidden input with YYYY-MM-DD (range: name-from, name-to).
id, className, popupLabel, aria-labelStandard. aria-label is needed when there is no FieldLabel.

DatePicker: value, defaultValue (Date | null), onValueChange(value: Date | null). It closes on pick.

DateRangePicker: value, defaultValue (DateRange), onValueChange(value: DateRange), numberOfMonths (1 | 2; default two from 640px wide, else one). It closes when both ends are chosen.

TimePicker:

PropTypeDefaultDescription
value / defaultValuestring | nullnull24-hour "HH:mm".
onValueChange(value: string | null) => voidnoneCalled with "HH:mm".
hourCycle12 | 24from localeDisplay cycle.
minuteStepnumber1Minutes between options.
disabled, locale, dir, name, id, className, aria-labelStandard.

Examples

import { DateRangePicker, Field, FieldLabel, TimePicker } from "@fadymondy/nasaq/web";

export function Arabic() {
  return (
    <div dir="rtl" lang="ar">
      <Field>
        <FieldLabel>الفترة</FieldLabel>
        <DateRangePicker locale="ar-SA" />
      </Field>
      <Field>
        <FieldLabel>وقت الاجتماع</FieldLabel>
        <TimePicker locale="ar-SA" defaultValue="14:30" minuteStep={15} />
      </Field>
    </div>
  );
}

Accessibility

The trigger is a button with aria-haspopup="dialog"; FieldLabel targets it. Focus moves to the selected day when the popup opens and returns to the trigger on close. Calendar keys are listed in the Calendar README. TimePicker segments are native selects labelled Hour / Minute / AM-PM (Arabic built in); the hour segment is the Field control.

RTL & i18n

Trigger text, month names and day periods follow the locale; digits stay Western. The popup and calendar mirror in RTL. Pass locale/dir when the picker is outside a NasaqProvider.

Styling & tokens

Same control tokens as Input and Select. Target data-invalid, data-popup-open and data-placeholder on the trigger.

Do / Don't

  • Do label every picker (FieldLabel or aria-label).
  • Don't parse the trigger text; read the value from onValueChange.

Lab

https://docs.nasaqui.com/?path=/docs/components-pickers-datepicker--docs

On this page