انتقل إلى المحتوى
TopClass UI

منتقي التاريخ

يوم واحد يُختار من شهر. يُحمَّل التقويم عند فتحه أول مرة، وكل اسم شهر وكل رقم يأتي من Intl.

client - الحجم لم يُقَس بعد, عند الطلب

منتقي التاريخ

client - الحجم لم يُقَس بعد, عند الطلب

يوم واحد يُختار من شهر. يُحمَّل التقويم عند فتحه أول مرة، وكل اسم شهر وكل رقم يأتي من Intl.

تثبيت

جرّبه

size
invalid
fullWidth
placement
firstDayOfWeek

الشيفرة

date-picker.tsx
import { DatePicker } from 'topclassui/date-picker'

<div className="grid justify-items-start gap-1.5">
  <label htmlFor="date-picker-playground" className="text-sm text-body">Check-in</label>
  <DatePicker id="date-picker-playground" defaultValue="2026-09-22" />
</div>

القيمة تاريخ بصيغة ISO، أي YYYY-MM-DD؛ والصيغة المعروضة تأتي من لغة المزوّد.

كل الحالات، بدون تمرير الفأرة

3 حالات
Pick a weekday.

أو استورده من الحزمة

topclassui/date-picker
import { DatePicker } from 'topclassui/date-picker'

ثبّت مرة واحدة:npm i topclassui@beta zod

أمثلة

  • value وdefaultValue تاريخ بصيغة ISO أو null؛ والنص الذي لا يمثّل يومًا حقيقيًا، مثل 2026-02-30، يُعدّ null.
  • مع name يرسل حقل مخفي التاريخ بصيغة ISO، وقيمة فارغة إن لم يُختر شيء. وقبل الترطيب يرسل القيمة الافتراضية.
  • minDate وmaxDate تاريخان بصيغة ISO؛ اليوم الواقع خارجهما يخفت ولا يمكن اختياره، وأزرار الشهر تتوقف عندهما.
  • يبدأ الأسبوع من firstDayOfWeek، من 1 (الاثنين) إلى 7 (الأحد)؛ وإن لم يُمرَّر، فمن أول أيام الأسبوع في اللغة.
  • التقويم جزء مستقل يُحمَّل عند الفتح الأول. والشبكة ميلادية دائمًا، دون أي مكتبة تواريخ.
basic
in-field
Rooms are ready from 15:00
limits
week-start
form
sizes
بالعربية، من اليمين إلى اليسار

الخصائص

خصائص DatePicker
الخاصيةالنوعالافتراضيالحدودالوصف
aria-labelstring--The name read out when no visible label names the control.
aria-labelledbystring--The id of the visible text that names the control.
idstring--The id a <label htmlFor> points at.
classNamestring--On the trigger, merged last, so a consumer class wins a conflict with its own.
containerBase.Portal.Props['container']--Where the calendar mounts; <body> by default.
defaultValuestring | null--The day of the first render, and the one a form reset brings back.
firstDayOfWeeknumber, min 1, max 7-min 1, max 7DatePicker: the first column, 1 (Monday) to 7 (Sunday), rounded and clamped; left out, the locale's.
formstring--The id of a form elsewhere on the page that the form input belongs to.
fullWidthbooleanfalse-DatePicker: the box fills the width of its parent instead of taking the width of an Input.
invalidbooleanfalse-DatePicker: marks the date as wrong: sets aria-invalid on the trigger, whose line turns to danger and thickens.
maxDatestring"9999-12-31"-DatePicker: the last day that can be chosen, clamped like minDate and raised to it when below.
minDatestring"0001-01-01"-DatePicker: the first day that can be chosen, an ISO date clamped to 0001-01-01 to 9999-12-31.
namestring--The form input's name: the form sends name=YYYY-MM-DD, and name= when empty.
onValueChange((value: string) => void)--Called with the ISO date of the day chosen. Client-only.
placeholderstring--The text of an empty trigger. Left out, the provider's datePicker.placeholder.
placementtop | top-start | top-end | bottom | bottom-start | bottom-end | start | start-top | start-bottom | end | end-top | end-bottom"bottom-start"-DatePicker: the side and alignment the calendar opens at; start and end mirror in Arabic.
refRef<HTMLButtonElement>--The trigger, a <button aria-haspopup="dialog">.
requiredboolean--Blocks an empty submit, with or without script; the trigger is described as required.
sizexs | sm | md | lg | xl | custom"md"-DatePicker: the height, the inline padding and the type step of the trigger, and its width with them; custom emits no size classes.
valuestring | null--The chosen day as an ISO date, YYYY-MM-DD, or null. A string that is not a real day counts as null.

لوحة المفاتيح وإمكانية الوصول

لوحة مفاتيح DatePicker
المفاتيحما يفعله
EnterSpaceعلى الزر، يفتحان التقويم على اليوم المختار، أو على اليوم الحالي؛ وفي الشبكة، يختاران اليوم ويغلقانه.
ArrowLeftArrowRightينقلان يومًا إلى الوراء أو إلى الأمام.
ArrowUpArrowDownينقلان أسبوعًا إلى الوراء أو إلى الأمام.
HomeEndينتقلان إلى أول يوم أو آخر يوم في الصف، داخل الشهر.
PageUpPageDownينقلان شهرًا؛ ومع Shift سنة. ويبقى اليوم داخل الشهر.
Escapeيغلق التقويم دون تغيير ويعيد التركيز إلى الزر.
Tabيدور بين السابق والتالي والإغلاق والشبكة.
  • الاسم مطلوب: id لتسمية <label htmlFor>، أو aria-label، أو aria-labelledby. التسمية تسمّي الزر، واليوم هو وصفه.
  • يتبع التقويم نمط حوار اختيار التاريخ في ARIA Authoring Practices؛ وما دام مفتوحًا يبقى التركيز فيه، مسمّى باسم شهره.
  • required يصف الزر بأنه مطلوب، لأن الزر لا يحمل aria-required. وinvalid يحوّل خطه إلى لون الخطر ويزيد سمكه.

من اليمين إلى اليسار

تأتي أسماء الشهور والأيام بالعربية، ويبدأ الأسبوع من السبت في ar، ويحاذي التقويم الحافة اليمنى للزر. وArrowLeft هو اليوم التالي.

الخادم والمتصفح

مكوّن متصفح: يُعرض على الخادم ثم يُرطَّب في المتصفح.

الملفات: index.tsx, client.tsx.

على الشارة: client - الحجم لم يُقَس بعد, عند الطلب.