منتقي التاريخ
يوم واحد يُختار من شهر. يُحمَّل التقويم عند فتحه أول مرة، وكل اسم شهر وكل رقم يأتي من 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
basic.tsx
import { DatePicker } from 'topclassui/date-picker'
/** A label that points at the trigger by its id: the server prints the day in the provider's locale, and the form
* input holds it as an ISO date. */
export default function Demo() {
return (
<div className="grid justify-items-start gap-1.5">
<label htmlFor="date-picker-basic" className="text-sm text-body">Check-in</label>
<DatePicker id="date-picker-basic" defaultValue="2026-09-22" />
</div>
)
}
in-field
Rooms are ready from 15:00
in-field.tsx
import { Field } from 'topclassui/field'
import { DatePicker } from 'topclassui/date-picker'
/** The card's sample: the Field's control object spreads onto the DatePicker as it is, so the label names the trigger
* and the hint describes it after the day. */
export default function Demo() {
return (
<Field name="checkIn" label="Check-in" hint="Rooms are ready from 15:00">
{(control) => (
<DatePicker
{...control}
defaultValue="2026-10-02"
minDate="2026-09-25"
maxDate="2027-03-31"
/>
)}
</Field>
)
}
limits
limits.tsx
import { DatePicker } from 'topclassui/date-picker'
/** The card's dates: a day from 25 September 2026 to 31 March 2027. The days outside are dimmed and cannot be chosen,
* and the previous button stops at September. */
export default function Demo() {
return (
<div className="grid justify-items-start gap-1.5">
<label htmlFor="date-picker-limits" className="text-sm text-body">Check-in</label>
<DatePicker id="date-picker-limits" name="checkIn" defaultValue="2026-10-02" minDate="2026-09-25" maxDate="2027-03-31" />
</div>
)
}
week-start
week-start.tsx
import { TopClassProvider } from 'topclassui/provider'
import { DatePicker } from 'topclassui/date-picker'
/** The first column: Monday, then Saturday, then left to the locale, which for British English is Monday too. */
export default function Demo() {
return (
<div className="grid justify-items-start gap-3">
<DatePicker aria-label="Monday first" firstDayOfWeek={1} defaultValue="2026-09-22" />
<DatePicker aria-label="Saturday first" firstDayOfWeek={6} defaultValue="2026-09-22" />
<TopClassProvider direction="ltr" locale="en-GB">
<DatePicker aria-label="The locale's first day" defaultValue="2026-09-22" />
</TopClassProvider>
</div>
)
}
form
form.tsx
import { Button } from 'topclassui/button'
import { DatePicker } from 'topclassui/date-picker'
/** The DatePicker carries the name and the default. It sends checkIn=2026-10-02, before any script runs and after. */
export default function Demo() {
return (
<form className="grid justify-items-start gap-3">
<label htmlFor="date-picker-form" className="text-sm text-body">Check-in</label>
<DatePicker id="date-picker-form" name="checkIn" defaultValue="2026-10-02" required />
<Button type="submit">Save</Button>
</form>
)
}
sizes
sizes.tsx
import { DatePicker } from 'topclassui/date-picker'
const SIZES = [
{ size: 'xs', label: 'Extra small' },
{ size: 'sm', label: 'Small' },
{ size: 'md', label: 'Medium' },
{ size: 'lg', label: 'Large' },
{ size: 'xl', label: 'Extra large' },
] as const
/** The five sizes of the trigger: the height, the padding and the type step change, and the width follows the type step. */
export default function Demo() {
return (
<div className="grid justify-items-start gap-3">
{SIZES.map(({ size, label }) => (
<DatePicker key={size} aria-label={label} size={size} defaultValue="2026-09-22" />
))}
</div>
)
}
بالعربية، من اليمين إلى اليسار
rtl.tsx
import { TopClassProvider } from 'topclassui/provider'
import { DatePicker } from 'topclassui/date-picker'
/** Arabic, inside TopClassProvider as the root layout would mount it: Arabic month names, the week from Saturday,
* the icon at the right, the calendar lined up with the right edge of the trigger, and ArrowLeft the next day. */
export default function Demo() {
return (
<TopClassProvider direction="rtl" locale="ar">
<div dir="rtl" lang="ar" className="grid justify-items-start gap-1.5">
<label htmlFor="date-picker-rtl" className="text-sm text-body">تاريخ الوصول</label>
<DatePicker id="date-picker-rtl" name="checkIn" defaultValue="2026-09-22" />
</div>
</TopClassProvider>
)
}
الخصائص
لوحة المفاتيح وإمكانية الوصول
- الاسم مطلوب:
idلتسمية<label htmlFor>، أوaria-label، أوaria-labelledby. التسمية تسمّي الزر، واليوم هو وصفه. - يتبع التقويم نمط حوار اختيار التاريخ في ARIA Authoring Practices؛ وما دام مفتوحًا يبقى التركيز فيه، مسمّى باسم شهره.
requiredيصف الزر بأنه مطلوب، لأن الزر لا يحمل aria-required. وinvalidيحوّل خطه إلى لون الخطر ويزيد سمكه.
من اليمين إلى اليسار
تأتي أسماء الشهور والأيام بالعربية، ويبدأ الأسبوع من السبت في ar، ويحاذي التقويم الحافة اليمنى للزر. وArrowLeft هو اليوم التالي.
الخادم والمتصفح
مكوّن متصفح: يُعرض على الخادم ثم يُرطَّب في المتصفح.
الملفات: index.tsx, client.tsx.
على الشارة: client - الحجم لم يُقَس بعد, عند الطلب.