ui
ธีม รูปแบบ CarbonKanok ภาษา English
ภาพรวมติดตั้งการย้ายไป 1.0ธีมและ layerดีไซน์ Kanokปรับแต่งหน้าตาไอคอนฟอร์มและการตรวจค่าใช้กับ frameworkใช้กับ AIButtonText inputText areaNumber inputSearchSelectDropdownComboboxMulti-selectCheckboxRadio buttonToggleDate pickerTime pickerSliderFile uploaderModalSide panelTearsheetNotificationToastTooltipDefinition tooltipPopoverToggletipMenuData tableStructured listPaginationContained listTree viewTabsBreadcrumbLinkPagination navContent switcherAccordionProgress indicatorUI shellTagTileCardProduct cardCode snippetCopy buttonUser avatarTruncated textListLoadingInline loadingProgress barSkeletonBadge indicatorStatus indicatorGridHeadingLayerAction setPage headerBig numberEdit in placeแนะนำText inputText areaNumber inputSearchSelectDropdownComboboxMulti-selectCheckboxRadio buttonToggleDate pickerTime pickerSliderFile uploaderTabsPagination navContent switcherTooltipDefinition tooltipPopoverMenuAccordionProgress indicatorUI shellModalSide panelTearsheetNotificationToastData tableStructured listPaginationTree viewCode snippetCopy buttonTruncated textLoadingTagCardProduct cardEdit in place

Date picker

date picker รับวันที่ที่ผู้ใช้พิมพ์เองหรือเลือกจากปฏิทิน หน้าภาษาไทยแสดงปีเป็น พ.ศ. แต่โค้ดของคุณได้วันที่แบบ ISO ปี ค.ศ. เสมอ

HTMLReactReact + Tailwind<ui-date-picker label="วันที่เริ่มสัญญา" name="start" clearable></ui-date-picker> <UiDatePicker label="วันที่เริ่มสัญญา" name="start" clearable /> <DatePicker label="วันที่เริ่มสัญญา" name="start" clearable />

ติดตั้ง

npmshadcn · Web componentshadcn · React + Tailwindคัดลอกเองnpm install @purpurabog/ui npx shadcn@4 add @kanok-ui/date-picker @kanok-ui/calendar npx shadcn@4 add @kanok-ui/tw-date-picker # Web component # 1. ติดตั้ง dependency npm install lit@^3.3.0 # 2. คัดลอก "content" ของแต่ละไฟล์จาก # https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/date-picker.json # https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/calendar.json # ไปไว้ที่ target ของมัน: # components/ui/primitives/date-picker/calendar.styles.ts # components/ui/primitives/date-picker/calendar.ts # components/ui/primitives/date-picker/date-field.styles.ts # components/ui/primitives/date-picker/date-field.ts # components/ui/primitives/date-picker/date-picker-fields.ts # components/ui/primitives/date-picker/date-picker-popup.ts # components/ui/primitives/date-picker/date-picker-skeleton.ts # components/ui/primitives/date-picker/date-picker.styles.ts # components/ui/primitives/date-picker/date-picker.ts # components/ui/primitives/calendar/calendar-select.ts # components/ui/primitives/calendar/calendar.styles.ts # components/ui/primitives/calendar/calendar.ts # 3. ทำแบบเดียวกันกับ item ที่มันใช้ (registry/<name>.json): # core-date, core-overlay, core-popup, core-sheet, shared-element, shared-field, shared-form-control, shared-localize, shared-position, shared-quiet-focus, shared-skeleton, shared-slots, tokens # React + Tailwind # 1. ติดตั้ง dependency npm install @purpurabog/ui@^2.3.0 # 2. คัดลอก "content" ของแต่ละไฟล์จาก # https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/tw-date-picker.json # ไปไว้ที่ target ของมัน: # components/ui/react-tw/date-picker.tsx # 3. ทำแบบเดียวกันกับ item ที่มันใช้ (registry/<name>.json): # core-date, core-field, core-i18n, tw-calendar, tw-field, tw-i18n, tw-skeleton, tw-theme, tw-utils

npm ให้ทุก component จากแพ็กเกจ ส่วน shadcn คัดลอกซอร์สเข้าแอปของคุณแทน เป็นสำเนาที่ล็อกเวอร์ชันนี้และแก้เองได้ คำสั่ง shadcn ต้องตั้ง registry @kanok-ui ใน components.json ครั้งเดียวก่อน ดู ติดตั้ง

วิธีใช้

HTMLReactReact + Tailwind<script type="module">import '@purpurabog/ui/date-picker';</script> <ui-date-picker label="วันที่เริ่มสัญญา" name="start"></ui-date-picker> import { UiDatePicker } from '@purpurabog/ui/react'; import type { UiDatePicker as DatePickerElement } from '@purpurabog/ui'; <UiDatePicker label="วันที่เริ่มสัญญา" name="start" value={start} onChange={(e) => setStart((e.target as DatePickerElement).value)} /> import { DatePicker } from '@/components/ui/react-tw/date-picker'; <DatePicker label="วันที่เริ่มสัญญา" name="start" value={start} onChange={setStart} />

UiDatePicker ยิง change แบบ native จึงใช้ prop onChange (ไม่มี onUiChange) ส่วน DatePicker ของ Tailwind ส่งสตริง ISO ให้ onChange โดยตรง

สิ่งที่ผู้ใช้เห็นกับค่าที่คุณได้

ผู้ใช้เห็นและพิมพ์วันที่ตามภาษาและปีศักราชของหน้า ส่วนโค้ดของคุณอ่านวันที่ ISO ค่าเดียวกันทุกภาษา picker สองตัวด้านล่างใช้ค่าเดียวกัน ลองเปลี่ยนตัวไหนก็ได้

value: 2026-10-10

HTMLReactReact + Tailwind<ui-date-picker id="date-picker-seen-th" label="วันที่ลงนาม" value="2026-10-10"></ui-date-picker> <ui-date-picker id="date-picker-seen-en" lang="en" label="Signed on" value="2026-10-10"></ui-date-picker> <p>value: <output id="date-picker-seen-out">2026-10-10</output></p> <script type="module"> const th = document.getElementById('date-picker-seen-th'); const en = document.getElementById('date-picker-seen-en'); for (const [from, to] of [[th, en], [en, th]]) { from.addEventListener('change', () => { to.value = from.value; document.getElementById('date-picker-seen-out').textContent = from.value || '(ว่าง)'; }); } </script> const [signed, setSigned] = useState('2026-10-10'); const onChange = (e: Event) => setSigned((e.target as DatePickerElement).value); <UiDatePicker label="วันที่ลงนาม" value={signed} onChange={onChange} /> <UiDatePicker lang="en" label="Signed on" value={signed} onChange={onChange} /> <p>value: <output>{signed || '(ว่าง)'}</output></p> const [signed, setSigned] = useState('2026-10-10'); <DatePicker label="วันที่ลงนาม" value={signed} onChange={setSigned} /> <DatePicker locale="en" label="Signed on" value={signed} onChange={setSigned} /> <p>value: <output>{signed || '(ว่าง)'}</output></p>
หน้าภาษาไทย หน้าภาษาอังกฤษ
ผู้ใช้เห็นและพิมพ์ 10/10/2569 10/10/2026
value, change และค่าที่ฟอร์มส่ง 2026-10-10 2026-10-10
  • value, min และ max เป็น yyyy-mm-dd ปี ค.ศ. เสมอ ถ้า value ไม่ใช่วันที่จริงในรูปแบบนี้ จะกลายเป็น '' เหมือน <input type="date">
  • element ยิง change เมื่อค่าถูกยืนยัน: ออกจากช่อง กด Enter เลือกจากปฏิทิน หรือกดล้าง อ่านค่าจาก event.target.value (และ endValue ในโหมดช่วง)
  • ช่องว่างยังส่ง name= ไปกับฟอร์มเหมือน date input แบบ native ส่วน picker ที่ disabled ไม่ส่งอะไรเลย

พิมพ์หรือเลือกจากปฏิทิน

ปฏิทินเปิดเมื่อช่องได้โฟกัส ทั้งจากการคลิกและการกด Tab โดยโฟกัสยังอยู่ในช่อง ผู้ใช้จึงพิมพ์ต่อได้ และปฏิทินเลื่อนตามสิ่งที่พิมพ์

  • ข้อความที่เป็นวันที่ครบตามรูปแบบของช่องแล้ว เช่น 10/10/2569 เป็นค่าของช่องทันที ส่วน change เกิดตอนยืนยัน (ออกจากช่องหรือกด Enter) ไม่ใช่ระหว่างพิมพ์
  • นอกนั้นอ่านตอนออกจากช่องหรือกด Enter โดยดึงตัวเลขออกจากสิ่งที่พิมพ์ s10/12/2569x จึงกลายเป็น 10/12/2569
  • ไม่มีการเดา วันที่ไม่ครบ (10/12) วันที่ไม่มีจริง (31/04/2569) หรือข้อความที่ไม่มีวันที่อยู่เลย จะค้างอยู่ในช่องพร้อมข้อความบอกว่าผิดตรงไหน และ value เป็น ''
  • วันที่ครบแต่อยู่นอก min / max หรือเป็นวันที่ isDateDisabled ไม่รับ จะถูกเก็บและยืนยันพร้อมข้อความของมันเอง ฟอร์มจะส่งไม่ได้จนกว่าจะแก้

ลองดู: พิมพ์วันที่ที่ไม่มีจริง หรือวันที่นอกปีที่กำหนด แล้วออกจากช่อง

HTMLReactReact + Tailwind<ui-date-picker label="วันสิ้นสุดสัญญา" helper-text="พิมพ์ 31/04/2569 แล้วออกจากช่อง"></ui-date-picker> <ui-date-picker label="วันที่ออกใบแจ้งหนี้" min="2026-01-01" max="2026-12-31" helper-text="เฉพาะวันที่ในปี 2569 ลองพิมพ์วันที่ในปี 2568 แล้วออกจากช่อง"></ui-date-picker> <UiDatePicker label="วันสิ้นสุดสัญญา" helperText="พิมพ์ 31/04/2569 แล้วออกจากช่อง" /> <UiDatePicker label="วันที่ออกใบแจ้งหนี้" min="2026-01-01" max="2026-12-31" helperText="เฉพาะวันที่ในปี 2569 ลองพิมพ์วันที่ในปี 2568 แล้วออกจากช่อง" /> <DatePicker label="วันสิ้นสุดสัญญา" helperText="พิมพ์ 31/04/2569 แล้วออกจากช่อง" /> <DatePicker label="วันที่ออกใบแจ้งหนี้" min="2026-01-01" max="2026-12-31" helperText="เฉพาะวันที่ในปี 2569 ลองพิมพ์วันที่ในปี 2568 แล้วออกจากช่อง" />

ข้อความเหล่านี้มีในตัวทั้งภาษาไทยและอังกฤษ error ขึ้นเมื่อไร และจะใส่ข้อความของตัวเองอย่างไร ดูที่ ฟอร์มและการตรวจค่า

พ.ศ. และภาษาไทย

ภาษามาจาก lang ที่ตัว element หรือ ancestor ที่ใกล้ที่สุด ถ้าไม่มีใช้ <html lang> ภาษาไทยให้ label และข้อความภาษาไทย ชื่อเดือนภาษาไทย และปีเป็น พ.ศ. (ค.ศ. + 543) ใส่ locale ถ้าต้องการกำหนดภาษาเฉพาะ picker ตัวนี้

HTMLReactReact + Tailwind<ui-date-picker lang="th" label="วันที่เริ่มสัญญา" value="2026-10-10"></ui-date-picker> <ui-date-picker lang="th" era="ce" label="วันที่เริ่มสัญญา (ค.ศ.)" value="2026-10-10"></ui-date-picker> <UiDatePicker lang="th" label="วันที่เริ่มสัญญา" value="2026-10-10" /> <UiDatePicker lang="th" era="ce" label="วันที่เริ่มสัญญา (ค.ศ.)" value="2026-10-10" /> <DatePicker locale="th" label="วันที่เริ่มสัญญา" defaultValue="2026-10-10" /> <DatePicker locale="th" era="ce" label="วันที่เริ่มสัญญา (ค.ศ.)" defaultValue="2026-10-10" />
  • era กำหนดปีที่ผู้ใช้เห็นและพิมพ์: be (พ.ศ. ค่าเริ่มต้นของภาษาไทย) หรือ ce (ค.ศ. ค่าเริ่มต้นของภาษาอื่น) ทุกภาษาเลือกได้ทั้งสองแบบ
  • ปีที่พิมพ์ใช้ศักราชเดียวกัน ในโหมด พ.ศ. ถ้าพิมพ์ปีต่ำกว่า 2400 (เช่น 2026) จะมีข้อความขอให้กรอกปี พ.ศ. ระบบไม่แปลงปีให้เองแบบเงียบ ๆ
  • ผู้ใช้พิมพ์เลขไทย (๐–๙) ได้ ระบบแปลงเป็น 0–9 ระหว่างพิมพ์
  • placeholder และข้อความช่วยตั้งต้นแสดงรูปแบบตามภาษาของหน้า: ภาษาไทยเป็น วว/ดด/ปปปป
  • React + Tailwind อ่าน <html lang> หรือ prop locale

รูปแบบวันที่

format กำหนดลำดับวัน เดือน ปี: dd/mm/yyyy (ค่าเริ่มต้น), mm/dd/yyyy หรือ yyyy-mm-dd เปลี่ยนแค่สิ่งที่ผู้ใช้เห็น value ยังเป็น ISO

HTMLReactReact + Tailwind<ui-date-picker label="วันครบกำหนด" format="yyyy-mm-dd" value="2026-10-10"></ui-date-picker> <UiDatePicker label="วันครบกำหนด" format="yyyy-mm-dd" value="2026-10-10" /> <DatePicker label="วันครบกำหนด" format="yyyy-mm-dd" defaultValue="2026-10-10" />

รูปแบบแสดงเป็นข้อความช่วยจนกว่าคุณจะใส่ helper-text (helperText ใน React + Tailwind) หลังจากนั้น screen reader ยังอ่านรูปแบบให้เหมือนเดิม

เลือกเป็นช่วง

range ให้สองช่องที่ใช้ปฏิทินร่วมกัน: value / name / label สำหรับวันเริ่ม และ end-value / end-name / end-label สำหรับวันสิ้นสุด ถ้าตั้งชื่อทั้งสองช่อง ฟอร์มจะได้ค่าสองรายการ ถ้าไม่มี end-name ตัว ui-date-picker จะส่งค่ารายการเดียวภายใต้ name เป็น start/end (2026-10-01/2026-10-05) แบบ cds-date-picker ของ Carbon ส่วน DatePicker ของ React + Tailwind จะส่งวันสิ้นสุดเฉพาะเมื่อมี endName

HTMLReactReact + Tailwind<ui-date-picker range label="วันเช็กอิน" end-label="วันเช็กเอาต์" name="from" end-name="to" value="2026-10-10" end-value="2026-10-14"></ui-date-picker> <UiDatePicker range label="วันเช็กอิน" endLabel="วันเช็กเอาต์" name="from" endName="to" value="2026-10-10" endValue="2026-10-14" /> <DatePicker range label="วันเช็กอิน" endLabel="วันเช็กเอาต์" name="from" endName="to" value={from} onChange={setFrom} endValue={to} onEndChange={setTo} />
  • เลือกวันแรกแล้วปฏิทินยังเปิดค้างไว้ให้เลือกวันสิ้นสุด วันระหว่างกลางมีไฮไลต์แบบแถบริบบิ้นต่อเนื่อง และมี preview ทั้งก่อนและหลังวันเริ่มระหว่างเลือกวันสิ้นสุด (ตามเมาส์หรือคีย์บอร์ด วันที่เลือกไม่ได้ไม่ทำให้ preview ขยับ)
  • ถ้าเลือกวันสิ้นสุดก่อนวันเริ่ม ระบบสลับสองค่าให้
  • ถ้ามีช่วงครบแล้ว การเลือกครั้งถัดไปเริ่มช่วงใหม่ (แบบ Cally) และ change เกิดเมื่อเลือกครบทั้งสองวัน
  • ถ้าพิมพ์วันสิ้นสุดก่อนวันเริ่ม ค่าจะค้างไว้พร้อมข้อความแจ้ง ไม่สลับให้

ปฏิทินสองเดือน (Two-Month Range Picker)

ใส่ months="2" เพื่อแสดงปฏิทินสองเดือนเคียงข้างกันในหน้าจอขนาดกว้าง เหมาะกับระบบจองห้องพัก ตั๋วเครื่องบิน หรือสัญญาเช่าที่มีช่วงเวลายาวข้ามเดือน:

HTMLReactReact + Tailwind<ui-date-picker range months="2" label="วันไป" end-label="วันกลับ" name="depart" end-name="return" value="2026-10-15" end-value="2026-11-05"></ui-date-picker> <UiDatePicker range months={2} label="วันไป" endLabel="วันกลับ" name="depart" endName="return" value="2026-10-15" endValue="2026-11-05" /> <DatePicker range months={2} label="วันไป" endLabel="วันกลับ" name="depart" endName="return" value={depart} onChange={setDepart} endValue={ret} onEndChange={setRet} />

จำกัดวันที่เลือกได้

min และ max รับวันที่ ISO วันที่อยู่นอกช่วงจะเป็นสีจาง และปุ่มเลื่อนเดือนจะหยุดที่ขอบนั้น

ถ้าจะปิดบางวัน (เสาร์-อาทิตย์ วันหยุด) ใช้ isDateDisabled: ฟังก์ชันที่คืน true หรือคืนข้อความเพื่อใช้เป็นข้อความแจ้งผู้ใช้ ใน web component เป็น property จึงต้องตั้งด้วย JavaScript:

HTMLReactReact + Tailwind<ui-date-picker id="date-picker-delivery" label="วันจัดส่ง" min="2026-01-01" max="2026-12-31"></ui-date-picker> <script type="module"> document.getElementById('date-picker-delivery').isDateDisabled = (date) => date.getDay() === 0 || date.getDay() === 6 ? 'ไม่มีบริการจัดส่งวันเสาร์-อาทิตย์' : false; </script> const weekend = (date: Date) => date.getDay() === 0 || date.getDay() === 6 ? 'ไม่มีบริการจัดส่งวันเสาร์-อาทิตย์' : false; <UiDatePicker label="วันจัดส่ง" min="2026-01-01" max="2026-12-31" isDateDisabled={weekend} /> const weekend = (date: Date) => date.getDay() === 0 || date.getDay() === 6 ? 'ไม่มีบริการจัดส่งวันเสาร์-อาทิตย์' : false; <DatePicker label="วันจัดส่ง" min="2026-01-01" max="2026-12-31" isDateDisabled={weekend} />

ปุ่มล้างและปุ่มวันนี้

clearable เพิ่มปุ่ม × ในช่องเมื่อมีข้อความ show-today เพิ่มปุ่ม "วันนี้" ใต้ปฏิทิน (Carbon ไม่มี ตัวนี้ต้องเปิดเอง) first-day กำหนดวันแรกของสัปดาห์ ตั้งแต่ 0 (อาทิตย์ ค่าเริ่มต้น) ถึง 6

HTMLReactReact + Tailwind<ui-date-picker label="วันประชุม" clearable show-today first-day="1"></ui-date-picker> <UiDatePicker label="วันประชุม" clearable showToday firstDay={1} /> <DatePicker label="วันประชุม" clearable showToday firstDay={1} />

ขนาดและแบบ fluid

size: sm 32px, md 40px (ค่าเริ่มต้น ตาม Carbon), lg 48px สเกลเดียวกับ text input ส่วน fluid หรือการวางไว้ในฟอร์มแบบ fluid (<ui-fluid-form>, FluidForm ใน React + Tailwind) ให้ช่องแบบ fluid ของ Carbon คือกล่องสูง 64px ที่มี label อยู่ข้างใน ทั้งสอง prop ใช้ชื่อเดียวกันใน React และ React + Tailwind

HTMLReactReact + Tailwind<ui-date-picker size="sm" label="วันที่ลงรายการ (sm)" value="2026-10-10"></ui-date-picker> <ui-date-picker size="lg" label="วันที่ลงรายการ (lg)" value="2026-10-10"></ui-date-picker> <ui-date-picker fluid range label="วันเริ่มเช่า" end-label="วันสิ้นสุดการเช่า" value="2026-11-01" end-value="2027-10-31"></ui-date-picker> <UiDatePicker size="sm" label="วันที่ลงรายการ (sm)" value="2026-10-10" /> <UiDatePicker size="lg" label="วันที่ลงรายการ (lg)" value="2026-10-10" /> <UiDatePicker fluid range label="วันเริ่มเช่า" endLabel="วันสิ้นสุดการเช่า" value="2026-11-01" endValue="2027-10-31" /> <DatePicker size="sm" label="วันที่ลงรายการ (sm)" defaultValue="2026-10-10" /> <DatePicker size="lg" label="วันที่ลงรายการ (lg)" defaultValue="2026-10-10" /> <DatePicker fluid range label="วันเริ่มเช่า" endLabel="วันสิ้นสุดการเช่า" defaultValue="2026-11-01" defaultEndValue="2027-10-31" />

แบบมีขอบ (ดีไซน์ Kanok)

ในดีไซน์ Kanok ช่องกรอกเป็นแบบ filled โดยปกติ คือพื้นเทาอ่อน ไม่มีขอบ ใส่ data-field-variant="outlined" ที่ element ที่ครอบช่อง (เช่น <form> หรือ <html> ถ้าต้องการทั้งแอป) จะเปลี่ยนเป็นขอบ 1px บนพื้นใส ส่วน focus ยังเป็นวงแสงสีฟ้าเหมือนเดิม attribute นี้ไม่มีผลในดีไซน์ Carbon ตัวอย่างด้านล่างจึงครอบด้วย data-design="kanok" ดูรายละเอียดทั้งหมดที่ ดีไซน์ Kanok

HTMLReactReact + Tailwind<div data-design="kanok" data-theme="paper" data-field-variant="outlined"> <ui-date-picker label="วันที่เริ่มสัญญา" name="start" clearable></ui-date-picker> </div> <div data-field-variant="outlined"> <UiDatePicker label="วันที่เริ่มสัญญา" name="start" clearable /> </div> <div data-field-variant="outlined"> <DatePicker label="วันที่เริ่มสัญญา" name="start" clearable /> </div>

ข้อความช่วย error และคำเตือน

helper-text บอกว่าวันที่นี้ใช้ทำอะไร (slot helper-text รับ markup ได้) warn กับ warn-text เตือนวันที่ที่เลือกได้แต่ผิดปกติ และไม่กันการส่งฟอร์ม invalid กับ invalid-text แสดง error จากการตรวจของคุณเอง เช่น ผลจาก server ในโหมดช่วง คำเตือนแสดงใต้ช่องวันเริ่ม

HTMLReactReact + Tailwind<ui-date-picker label="วันที่มีผล" helper-text="วันที่เริ่มใช้อัตราใหม่"></ui-date-picker> <ui-date-picker label="วันครบกำหนดชำระ" value="2026-10-03" warn warn-text="วันนี้เป็นวันเสาร์ ธนาคารจะโอนวันจันทร์"></ui-date-picker> <ui-date-picker label="วันสิ้นสุดสัญญา" value="2026-09-30" invalid invalid-text="วันสิ้นสุดต้องอยู่หลังวันเริ่ม 01/10/2569"></ui-date-picker> <UiDatePicker label="วันที่มีผล" helperText="วันที่เริ่มใช้อัตราใหม่" /> <UiDatePicker label="วันครบกำหนดชำระ" value="2026-10-03" warn warnText="วันนี้เป็นวันเสาร์ ธนาคารจะโอนวันจันทร์" /> <UiDatePicker label="วันสิ้นสุดสัญญา" value="2026-09-30" invalid invalidText="วันสิ้นสุดต้องอยู่หลังวันเริ่ม 01/10/2569" /> <DatePicker label="วันที่มีผล" helperText="วันที่เริ่มใช้อัตราใหม่" /> <DatePicker label="วันครบกำหนดชำระ" defaultValue="2026-10-03" warn warnText="วันนี้เป็นวันเสาร์ ธนาคารจะโอนวันจันทร์" /> <DatePicker label="วันสิ้นสุดสัญญา" defaultValue="2026-09-30" invalid invalidText="วันสิ้นสุดต้องอยู่หลังวันเริ่ม 01/10/2569" />

อ่านอย่างเดียวและปิดใช้งาน

readonly แสดงและส่งค่า แต่พิมพ์ไม่ได้และเปิดปฏิทินไม่ได้ disabled ทำให้ช่องเป็นสีจาง ไม่ส่งค่าและไม่ตรวจค่า <fieldset> ที่ disabled ครอบอยู่ก็ให้ผลเหมือนกัน

HTMLReactReact + Tailwind<ui-date-picker label="วันที่ลงนาม" value="2026-10-10" readonly></ui-date-picker> <ui-date-picker label="วันที่ลงนาม" value="2026-10-10" disabled></ui-date-picker> <UiDatePicker label="วันที่ลงนาม" value="2026-10-10" readonly /> <UiDatePicker label="วันที่ลงนาม" value="2026-10-10" disabled /> <DatePicker label="วันที่ลงนาม" defaultValue="2026-10-10" readOnly /> <DatePicker label="วันที่ลงนาม" defaultValue="2026-10-10" disabled />

web component และ wrapper ของ React สะกดว่า readonly ส่วน React + Tailwind ใช้ readOnly

ใช้ในฟอร์ม

ถ้ามี required ฟอร์มจะส่งไม่ได้จนกว่าจะกรอกวันที่ ในโหมดช่วงต้องกรอกทั้งสองช่อง ฟอร์มได้วันที่ ISO ภายใต้ name (และ end-name) ลองกดส่งฟอร์มเปล่าด้านล่างเพื่อดูข้อความ

ส่งใบลา

ค่าที่ส่ง: ยังไม่มี

HTMLReactReact + Tailwind<form id="date-picker-form" method="dialog" style="display: grid; gap: 16px"> <ui-date-picker label="วันที่ยื่นคำขอ" name="requested" value="2026-10-10" required></ui-date-picker> <ui-date-picker range label="ลาตั้งแต่วันที่" end-label="ถึงวันที่" name="from" end-name="until" required></ui-date-picker> <div><ui-button type="submit">ส่งใบลา</ui-button></div> </form> <p>ค่าที่ส่ง: <output id="date-picker-form-out">ยังไม่มี</output></p> <script type="module"> const form = document.getElementById('date-picker-form'); form.addEventListener('submit', (event) => { event.preventDefault(); const entries = [...new FormData(form)].map(([key, value]) => `${key}=${value}`); document.getElementById('date-picker-form-out').textContent = entries.join(', '); }); </script> <form onSubmit={(e) => { e.preventDefault(); send(new FormData(e.currentTarget)); }}> <UiDatePicker label="วันที่ยื่นคำขอ" name="requested" value="2026-10-10" required /> <UiDatePicker range label="ลาตั้งแต่วันที่" endLabel="ถึงวันที่" name="from" endName="until" required /> <UiButton type="submit">ส่งใบลา</UiButton> </form> <form onSubmit={(e) => { e.preventDefault(); send(new FormData(e.currentTarget)); }}> <DatePicker label="วันที่ยื่นคำขอ" name="requested" defaultValue="2026-10-10" required /> <DatePicker range label="ลาตั้งแต่วันที่" endLabel="ถึงวันที่" name="from" endName="until" required /> <Button type="submit">ส่งใบลา</Button> </form>

send แทนโค้ดของคุณเอง

มือถือและแท็บเล็ต

บนมือถือ (จอสัมผัสที่แคบกว่า 42rem) picker="auto" (ค่าเริ่มต้น) เปิดปฏิทินใน bottom sheet คือ dialog ที่ชิดขอบล่างของจอ บนหน้าเว็บที่ถูกทำให้มืดลง

  • แตะที่ช่องเพื่อเปิด โดยโฟกัสอยู่ที่วันหนึ่งวัน คีย์บอร์ดบนจอจึงไม่ขึ้นมาบัง แค่โฟกัสที่ช่องยังไม่เปิด หลัง sheet ปิดแล้ว แตะที่ช่องอีกครั้งจะเป็นการพิมพ์
  • ปิดได้ด้วย Esc ปุ่ม × การปัดลงที่แถบด้านบน หรือแตะที่หน้าเว็บที่มืดลง ข้อความที่พิมพ์ไว้ถูกบันทึก และโฟกัสกลับไปที่ช่อง
  • ระหว่างที่เปิด หน้าเว็บด้านหลังใช้และเลื่อนไม่ได้ และระยะขอบของ sheet เว้นพื้นที่ปลอดภัยของเครื่องไว้ (แถบ home ติ่งกล้อง)

บนแท็บเล็ตและจอที่ใหญ่กว่านั้น ปฏิทินเปิดใต้ช่องเหมือนเดิม

picker เปิด
auto (ค่าเริ่มต้น) bottom sheet บนมือถือ และปฏิทินใต้ช่องบนอุปกรณ์อื่น
custom ปฏิทินใต้ช่องทุกอุปกรณ์
sheet bottom sheet ทุกอุปกรณ์
native ตัวเลือกวันที่ของ OS ซึ่งทำวันที่ isDateDisabled ให้จางไม่ได้ วันที่เลือกจากตัวนั้นจึงถูกตรวจเหมือนข้อความที่พิมพ์
<ui-date-picker label="วันที่นัด" picker="sheet"></ui-date-picker>

ปรับหน้าตา sheet ด้วย ::part(sheet) (ฉากหลังมืดใช้ ::part(sheet)::backdrop) ::part(sheet-grip) และ ::part(sheet-close) ส่วน --ui-sheet-radius กำหนดความมนของมุมด้านบน (ค่าเริ่มต้นเท่ากับความมนของเมนู) prop นี้ชื่อเดียวกันทุกแบบ

ใช้ปฏิทินเดี่ยว ๆ

ปฏิทินใน picker เป็น element ของมันเองชื่อ ui-calendar มาพร้อม import เดียวกัน เป็น view แบบ controlled: มันเลื่อนโฟกัสเองได้ แต่วันที่เลือกเป็นหน้าที่ของคุณ ฟัง ui-pick (detail { date } เป็น Date) แล้วตั้ง value:

HTMLReactReact + Tailwind<ui-calendar id="date-picker-calendar" style="max-width: 288px" locale="th" era="be" show-today></ui-calendar> <script type="module"> const calendarAlone = document.getElementById('date-picker-calendar'); calendarAlone.addEventListener('ui-pick', (event) => { const d = event.detail.date; const pad = (n) => String(n).padStart(2, '0'); calendarAlone.value = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`; }); </script> import { UiCalendar } from '@purpurabog/ui/react'; import { toIso } from '@purpurabog/ui/core'; <UiCalendar locale="th" era="be" value={day} showToday onUiPick={(e) => setDay(toIso(e.detail.date))} /> // npx shadcn@4 add @kanok-ui/tw-calendar import { Calendar } from '@/components/ui/react-tw/calendar'; import { toIso } from '@purpurabog/ui/core'; const [focus, setFocus] = useState(() => new Date()); <Calendar locale="th" era="be" value={day} focusDate={focus} onFocusDateChange={setFocus} onPick={(date) => setDay(toIso(date))} showToday />

เดือนที่แสดงตาม property focusDate (เป็น Date ค่าเริ่มต้นคือวันนี้) ui-calendar ใช้ภาษาของหน้าเหมือน picker (lang ที่ใกล้ที่สุด) และแสดงปี พ.ศ. เมื่อเป็นภาษาไทย ใส่ locale และ era เพื่อกำหนดเอง รับ min, max, isDateDisabled, range กับ end-value, first-day และ show-today เหมือน picker ส่วน Calendar ของ React + Tailwind ก็เป็นแบบ controlled เช่นกัน ต้องส่ง focusDate, onFocusDateChange และ onPick เสมอ

เลือกหลายวัน (Multiple Dates)

<ui-calendar multi> รองรับการเลือกหลายวันที่พร้อมกัน (แบบ Cally) โดยคลิกเพื่อเปิด/ปิดวันที่ในรายการ values:

HTML<ui-calendar multi values='["2026-10-05","2026-10-12","2026-10-19"]' locale="th" era="be"></ui-calendar>

สองเดือนพร้อมช่วงวันที่ (Dual-Month Calendar)

<ui-calendar range months="2"> แสดงปฏิทินสองเดือนพร้อมแถบริบบิ้นต่อเนื่อง:

HTML<ui-calendar range months="2" value="2026-10-10" end-value="2026-11-04" locale="th" era="be"></ui-calendar>

เลือกเดือนและปี (แบบ Cally)

หัวปฏิทินมี select แบบ native สองตัวแบบ Cally คือ <ui-calendar-select-month> และ <ui-calendar-select-year> เดือนที่อยู่นอก min / max ทั้งเดือนจะเลือกไม่ได้ ส่วนรายการปีมี 20 ปีรอบปีที่แสดง และตัดตาม min / max หน้าภาษาไทยแสดงปีเป็น พ.ศ. ถ้าแสดงหลายเดือน หัวปฏิทินจะมีแค่ select ปี เพราะแต่ละตารางมีชื่อเดือนของตัวเองอยู่แล้ว

ใส่เนื้อหาของคุณเองใน slot heading เพื่อแทน select ทั้งสองได้ select ที่ใส่ไว้ใน slot นี้ หรืออยู่ข้างในสิ่งที่ใส่ จะทำงานตามปฏิทินด้วย:

HTML<ui-calendar locale="th" era="be"> <div slot="heading"> <ui-calendar-select-month format-month="short"></ui-calendar-select-month> <ui-calendar-select-year max-years="5"></ui-calendar-select-year> </div> </ui-calendar>
Element Attribute ทำอะไร
ui-calendar-select-month format-month ชื่อเดือนแบบ long (ค่าเริ่มต้น) หรือ short
ui-calendar-select-year max-years จำนวนปีในรายการรอบปีที่แสดง (ค่าเริ่มต้น 20)

ตกแต่ง select ด้วย ui-calendar::part(month-select) และ ::part(year-select) ฝั่ง React + Tailwind Calendar มีหัวแบบเดียวกัน ส่วน headless ใช้ Calendar.MonthSelect และ Calendar.YearSelect

ตัวเลือกเพิ่มเติมของปฏิทิน (แบบ Cally)

HTMLReact + Tailwind<ui-calendar months="2" page-by="single" show-week-numbers locale="th" era="be"></ui-calendar> <Calendar focusDate={focus} onFocusDateChange={setFocus} onPick={pick} months={2} pageBy="single" showWeekNumbers />
ui-calendar / ui-date-picker React + Tailwind ทำอะไร
months months แสดง 1 ถึง 12 เดือนเรียงกัน ถ้า 12 เดือนจะแสดงทั้งปีเริ่มที่มกราคม
page-by="single" pageBy="single" ปุ่ม ‹ › เลื่อนทีละหนึ่งเดือนแม้แสดงหลายเดือน (ค่าเริ่มต้นเลื่อนทั้งหน้า)
show-week-numbers showWeekNumbers แสดงเลขสัปดาห์ ISO หน้าแต่ละสัปดาห์ และ popover ของ date picker จะกว้างขึ้น
show-outside-days showOutsideDays แสดงวันของเดือนอื่นเต็มหกสัปดาห์ ค่าเริ่มต้นเว้นว่างไว้และแสดงเฉพาะสัปดาห์ที่เดือนนั้นต้องใช้ แบบ Cally (เฉพาะแบบเดือนเดียว)
weekday-format weekdayFormat ชื่อวันบนหัวตารางแบบ narrow หรือ short (ค่าเริ่มต้นใช้ของคำแปล)
today today วันที่ให้ถือเป็นวันนี้ (ISO) ใช้กับเทสต์หรือภาพหน้าจอ
getDayParts (property เฉพาะ ui-calendar) dayClassName ชื่อ part หรือ class ของคุณเองสำหรับวันหนึ่ง ๆ เช่น วันหยุด หรือวันที่มีนัด

ตกแต่ง part ที่ getDayParts คืนมาด้วย ::part():

<style> ui-calendar::part(holiday) { color: var(--ui-error-text); } </style> <script type="module"> document.querySelector('ui-calendar').getDayParts = (d) => (d.getMonth() === 3 && d.getDate() === 13 ? 'holiday' : ''); </script>

event ที่ ui-calendar ส่งเพิ่ม:

  • ui-range-start และ ui-range-end (detail { date }) เมื่อเลือกปลายแต่ละด้านของช่วง ส่วน change จะส่งเมื่อเลือกครบทั้งสองด้านแล้ว
  • ui-page-change (detail { start, end }) เมื่อเดือนที่แสดงเปลี่ยน ฝั่ง React + Tailwind ใช้ onPageChange ของ Calendar

ตัวเลือกอื่น:

  • focus({ target: 'previous' | 'next' | 'day' }) ย้าย focus ไปที่ปุ่มลูกศรหรือที่วัน
  • slot previous และ next ใช้แทนไอคอนลูกศร ส่วน slot heading ใช้แทน select เดือนและปี
  • <ui-date-picker> รับ show-outside-days และ getDayParts (picker ส่งต่อชื่อ part ที่ได้ ใช้ ui-date-picker::part(holiday) ได้) และส่ง ui-range-start / ui-range-end ฝั่ง React + Tailwind DatePicker มี onRangeStart / onRangeEnd
  • ปุ่มวันมี part ตามสถานะของวันนั้น: selected, today, outside, disabled, disallowed, range-start, range-end, in-range และ day-0 … day-6 ส่วนเลขสัปดาห์มี part weeknumber
  • ในหน้าที่อ่านจากขวาไปซ้าย ปุ่ม ← และ → จะสลับทิศกัน

Skeleton

ระหว่างที่หน้ากำลังโหลดข้อมูล ให้แสดง <ui-date-picker-skeleton> แทนที่ picker เหมือน DatePickerSkeleton ของ Carbon ใส่ range ถ้าเป็นสองช่อง ตัวนี้ import แยกจาก @purpurabog/ui/date-picker-skeleton และ screen reader มองไม่เห็น

HTMLReactReact + Tailwind<ui-date-picker-skeleton></ui-date-picker-skeleton> <ui-date-picker-skeleton range></ui-date-picker-skeleton> import { UiDatePickerSkeleton } from '@purpurabog/ui/react'; <UiDatePickerSkeleton /> <UiDatePickerSkeleton range /> import { DatePickerSkeleton } from '@/components/ui/react-tw/date-picker'; <DatePickerSkeleton /> <DatePickerSkeleton range />

คีย์บอร์ด

ในช่องพิมพ์:

ปุ่ม ผล
พิมพ์ กรอกวันที่ ปฏิทินที่เปิดอยู่เลื่อนตามเมื่อวันที่ครบ
↓ เปิดปฏิทินและย้ายโฟกัสเข้าไป
Tab ไปช่องถัดไป (โหมดช่วงจากช่องวันเริ่มไปช่องวันสิ้นสุด) บันทึกข้อความที่พิมพ์ และปฏิทินปิดเมื่อโฟกัสออกจาก picker
Shift + Tab จากช่องวันเริ่ม: ปิดปฏิทินแล้วย้อนกลับ
Enter ยืนยันข้อความที่พิมพ์ ปิดปฏิทิน และส่งฟอร์มที่ช่องอยู่
Esc ปิดปฏิทิน

ในปฏิทิน:

ปุ่ม ผล
← / → วันก่อนหน้า / ถัดไป
↑ / ↓ วันเดียวกันของสัปดาห์ก่อน / ถัดไป
Home / End วันแรก / วันสุดท้ายของสัปดาห์
Page Up / Page Down เดือนก่อน / เดือนถัดไป
Shift + Page Up / Page Down ปีก่อน / ปีถัดไป
Enter, Space เลือกวันนั้น แล้วปิดปฏิทิน (โหมดช่วงปิดหลังเลือกวันสิ้นสุด)
Esc ปิด แล้วโฟกัสกลับไปที่ช่องพิมพ์
Tab วนอยู่ในปฏิทิน: ‹ เดือน ปี › และวัน (และปุ่มวันนี้) จากตัวสุดท้ายกลับไปตัวแรก ออกจากปฏิทินด้วย Esc หรือเลือกวัน
Shift + Tab วนแบบเดียวกันย้อนกลับ

ถ้าใช้เมาส์ เลือกเดือนหรือปีจาก select ที่หัวปฏิทินได้

Accessibility

  • ช่องพิมพ์เป็น combobox ที่เปิด dialog (aria-haspopup="dialog", aria-expanded) ปฏิทินเป็น dialog ชื่อ "เลือกวันที่" ที่มี grid ของปุ่มวัน ตาม pattern date picker dialog ของ WAI-ARIA
  • แต่ละวันถูกอ่านเป็นวันที่เต็ม (เช่น "วันเสาร์ที่ 10 ตุลาคม พ.ศ. 2569") วันนี้มี aria-current="date" วันที่เลือกมี aria-pressed วันที่เลือกไม่ได้มี aria-disabled
  • การเปลี่ยนเดือนถูกประกาศผ่าน live region แบบ polite
  • bottom sheet เป็น modal dialog ชื่อเดียวกัน หน้าเว็บด้านหลังเป็น inert จนกว่าจะปิด
  • ไอคอนปฏิทินเป็นแค่ภาพประกอบแบบ Carbon ไม่ใช่จุดหยุดของ Tab และการคลิกที่ไอคอนเท่ากับคลิกในช่องพิมพ์
  • error ตั้ง aria-invalid และผูกกับช่องด้วย aria-describedby เช่นเดียวกับคำอธิบายรูปแบบ

ต้องการแค่พฤติกรรมโดยไม่มี style: Headless Date picker

API

สร้างจากแพ็กเกจโดยตรง ใน React ส่ง property เป็น prop ชื่อเดียวกัน ส่วน event ก็เป็น prop เช่นกัน (ดูคอลัมน์ React)

<ui-date-picker> · React UiDatePicker

Attribute

Attribute Property ชนิด ค่าเริ่มต้น คำอธิบาย
label label string '' Visible label text; the label slot replaces it when markup is needed.
hide-label hideLabel boolean false Keep the label for screen readers but don't show it.
helper-text helperText string '' Helper text under the field, shown while there is no error or warning.
invalid-text invalidText string '' Error text shown while invalid or while the field fails validation.
invalid invalid boolean false Forces the error state, e.g. after server-side validation.
warn warn boolean false Non-blocking warning; shown when there is no error.
warn-text warnText string '' Text of the warning shown while warn.
value value string '' ISO yyyy-mm-dd (the start date in range mode).
name name string '' Reflected: form-associated elements submit under the name attribute.
range range boolean false Two fields sharing one calendar (Carbon datePickerType="range").
end-value endValue string '' Range mode: the end date, ISO yyyy-mm-dd.
end-name endName string '' Range mode: form entry name of the end date. Without it the range submits as one name entry start/end.
end-label endLabel string '' Range mode: label of the end field.
min min string '' Earliest selectable date, ISO yyyy-mm-dd.
max max string '' Latest selectable date, ISO yyyy-mm-dd.
format format DateFormat 'dd/mm/yyyy'
locale locale string '' Locale for names, labels and messages. Defaults to the nearest lang: the element's own, an ancestor's, then <html>'s, else the browser language.
era era Era | '' '' Year era shown and typed: be (พ.ศ.) or ce (ค.ศ.). Defaults to be for Thai locales.
first-day firstDay number 0 0 = Sunday … 6 = Saturday.
disabled disabled boolean false Disables the control; a disabled <fieldset> ancestor does the same.
required required boolean false Blocks form submission while the field is empty.
readonly readonly boolean false Shows and submits the value but blocks changes.
fluid fluid boolean false Carbon FluidDatePicker: each date box is a 64px box with its label inside. <ui-fluid-form> sets it for every field inside.
picker picker 'auto' | 'custom' | 'sheet' | 'native' 'auto' Which picker opens: auto (default) = our calendar, in a bottom sheet on a phone; custom = our calendar as a popover on every device; sheet = in a bottom sheet on every device; native = the OS date picker.
clearable clearable boolean false Shows a clear button inside the field while it has text.
show-today showToday boolean false Adds a "Today" button under the calendar.
months months number 1 Months to show side by side in the calendar, 1 to 12 (default 1, e.g. 2 for range picking).
page-by pageBy 'months' | 'single' 'months' With more than one month, ‹ › turn a whole page (months) or one month (single): the calendar's page-by.
show-outside-days showOutsideDays boolean false Show the days of the months before and after (by default they are blank): the calendar's show-outside-days.
show-week-numbers showWeekNumbers boolean false A column of ISO week numbers in the calendar: its show-week-numbers.
weekday-format weekdayFormat 'narrow' | 'short' | '' '' Weekday headings narrow or short: the calendar's weekday-format.
today today string '' The day the calendar marks as today, ISO (default the real today).
size size 'sm' | 'md' | 'lg' 'md' Field height, same scale as ui-text-input.

Property

Property ชนิด คำอธิบาย
getDayParts (date: Date) => string | undefined Extra part names for a calendar day, e.g. holiday: the calendar's getDayParts; the picker exports each name it returns, so ui-date-picker::part(holiday) styles those days.
isDateDisabled (date: Date) => boolean | string | undefined Property only. Return true for days that can't be chosen (weekends, holidays…), or a string to show that reason instead of the generic message.
willValidate (อ่านอย่างเดียว) Whether the field takes part in constraint validation (not while disabled), as natively.
labels (อ่านอย่างเดียว) The <label>s that point at this field.

Method

Method คำอธิบาย
setCustomValidity(message) Like <input>.setCustomValidity(): a non-empty message makes the field invalid (and is shown as its error once touched) until cleared with ''.

Event

Event React คำอธิบาย
change onChange When a committed value (start or end) changes: blur, Enter, a calendar pick or clear.
ui-range-start onUiRangeStart Detail { date }, range: a calendar pick began a range (its start), as Cally's rangestart; change waits for the end
ui-range-end onUiRangeEnd Detail { date }, range: a calendar pick finished a range (its end), as Cally's rangeend A typed date outside min/max is still committed, with the field reporting the range error.

Slot

Slot คำอธิบาย
label Label content with markup; the label attribute is the plain-text fallback
helper-text Helper text with markup (links, bold); overrides helper-text
warn-text Warning text shown while warn; overrides warn-text
invalid-text Error text shown while invalid; overrides invalid-text
end-label Label of the end field in range mode; overrides end-label

CSS part

Part คำอธิบาย
base The field box (range: also start-base / end-base; same for every field part)
label The label
input The text box
clear-button The × button
toggle The calendar icon (decorative, as Carbon)
status-icon The error / warning icon
helper-text The helper line
warning-text The warning line
warn-text Same line as warning-text (named after the warn-text attribute / slot)
error-text The error line
invalid-text Same line as error-text (named after the invalid-text attribute / slot)
calendar The popover shell (in the bottom sheet: the sheet's panel)
sheet The bottom sheet <dialog> on a phone (picker="auto" / sheet; style its scrim with ::part(sheet)::backdrop)
sheet-grip The sheet's top bar, which a swipe down closes
sheet-close The sheet's × button
header Calendar month / year row
nav Previous / next month buttons
heading The month and year selects' row
month-select The month select (<ui-calendar-select-month>'s select)
year-select The year select (<ui-calendar-select-year>'s select)
month-title A month's name over its grid when several show
grid The table of days
day Each day button (its state also: selected, today, outside, disabled, disallowed, range-start, range-end, in-range, and the names getDayParts returns)
weeknumber A week-number cell (show-week-numbers)
today-button The optional "Today" button

CSS custom property

Custom property ค่าเริ่มต้น คำอธิบาย
--ui-field-border Border on every side of the box (default none: Carbon's underline only; Kanok: a 1px outline)
--ui-field-disabled-border-color Border colour when disabled (default: the underline transparent)
--ui-field-readonly-border-color Border colour when read-only (default: a hairline underline)
--ui-field-radius Corner radius of the box (default 0; Kanok: 6px)
--ui-field-background Fill of the box (default --ui-surface-1; Kanok: transparent)
--ui-label-font Font of the label (default --ui-font-caption; Kanok: 14px semibold)
--ui-label-color Colour of the label (default --ui-ink-muted; Kanok: --ui-ink)
--ui-menu-radius / --ui-menu-border / --ui-menu-shadow - Corners, border and shadow of the calendar (the menu settings)
--ui-sheet-radius The bottom sheet's top corners (default: the menu radius)
--ui-modal-scrim The bottom sheet's scrim, as the modal's (default Carbon's overlay)
--ui-calendar-day-radius Corner radius of a day (default 0; Kanok: 6px)
--ui-calendar-today-dot-radius Corner radius of today's dot (default 0, a square; Kanok: 50%, a dot)
--ui-field-readonly-background The box's fill when read-only (default transparent; Kanok: a faint ink tint, so read-only reads as set and never weaker than disabled)
--ui-fluid-background / --ui-fluid-gap - A fluid box's fill and the space under it (default the layer's fill, 0: boxes that touch; Kanok: transparent, 8px)
--ui-icon-control-radius Corners of its small icon buttons, their hover fill and ring (default 0; Kanok: round)
--ui-focus-offset outline-offset of the month arrows' and Today's focus ring (default -2px: inside; Kanok: 2px outside)

<ui-calendar> · React UiCalendar

Attribute

Attribute Property ชนิด ค่าเริ่มต้น คำอธิบาย
value value string '' Chosen day (start day in range mode), ISO yyyy-mm-dd.
end-value endValue string '' Range mode: chosen end day, ISO yyyy-mm-dd.
range range boolean false Whether range selection is enabled.
multi multi boolean false Multi-date selection mode: select multiple individual dates (like Cally's calendar-multi).
values values string[] | string [] Selected dates in multi mode (array or comma/space-separated ISO string).
months months number 1 Months on show side by side, 1 to 12 (default 1; 12 paged by the page is a calendar year, from January).
page-by pageBy 'months' | 'single' 'months' With more than one month, ‹ › and the keys turn a whole page (months, the default) or one month (single), as Cally's page-by.
show-outside-days showOutsideDays boolean false Show the days of the months before and after, in six weeks (Cally show-outside-days); by default they are blank and only the weeks the month needs show. Several months never show them.
show-week-numbers showWeekNumbers boolean false A column of ISO week numbers before the weeks (Cally show-week-numbers).
weekday-format weekdayFormat 'narrow' | 'short' | '' '' Weekday headings narrow (S / อา) or short (Sun / อา.); by default narrow in Thai, short otherwise (Cally format-weekday).
today today string '' The day marked as today, ISO (default the real today): for tests, demos and another time zone (Cally today).
active-field activeField 'start' | 'end' 'start' Range mode: which end a pick will set; drives the preview highlight.
min min string '' Minimum selectable ISO date.
max max string '' Maximum selectable ISO date.
locale locale string '' BCP 47 locale for names and labels. Defaults to the nearest lang.
era era Era | '' '' Year era: be (พ.ศ.) or ce (ค.ศ.). Defaults to be for Thai locales.
first-day firstDay number 0 0 = Sunday … 6 = Saturday.
show-today showToday boolean false Whether to display the "Today" footer shortcut button.

Property

Property ชนิด คำอธิบาย
getDayParts (date: Date) => string | undefined Extra part names for a day, e.g. holiday (Cally getDayParts).
focusDate Day that holds the roving tab stop; its month is shown.
isDateDisabled (date: Date) => boolean | string | undefined Callback to disable individual dates (e.g. weekends, holidays).
multiValues string[] (อ่านอย่างเดียว) Selected dates as clean ISO array in multi mode.

Method

Method คำอธิบาย
focusDay() Puts DOM focus on the day that holds the roving tab stop.
tabStops() The calendar's Tab stops in order: ‹, its own month and year selects (not when heading is slotted), ›, the day that holds the tab stop and Today.
focus(options) Focus on the day with the tab stop, or with { target: 'previous' | 'next' } on a month arrow (Cally's focus()).

Event

Event React คำอธิบาย
ui-page-change onUiPageChange Detail { start, end }, the first and last day shown after the months on show changed (Cally pagechange)
ui-multi-pick onUiMultiPick Detail { date, values }, in multi mode when a day is toggled
change ไม่มี (ใช้ ref) Detail { value, endValue, values }, native-like change event on a pick (with range, once both ends are picked)
ui-pick onUiPick Detail { date }, when a day is activated
ui-focus-change onUiFocusChange Detail { date }, when keyboard or navigation moves the focused date
ui-range-start onUiRangeStart Detail { date }, with range: the first end was picked (Cally rangestart)
ui-range-end onUiRangeEnd Detail { date }, with range: the second end was picked (Cally rangeend)

Slot

Slot คำอธิบาย
previous Replaces the previous button's arrow icon
next Replaces the next button's arrow icon
heading Replaces the month and year selects; <ui-calendar-select-month> / <ui-calendar-select-year> put here follow the calendar

CSS part

Part คำอธิบาย
months Multi-month layout container
month-view Container of a single month
month-title A month's name above its grid when two months show (the header then has the year only)
header Month / year row container
nav Previous / next navigation buttons
prev-button The previous month button
next-button The next month button
heading The month and year selects' row (the heading slot)
month-select The default heading's month select (<ui-calendar-select-month>'s select)
year-select The default heading's year select (<ui-calendar-select-year>'s select)
grid The table grid of days
table The table grid of days
thead The table header row with weekday labels
th Individual weekday heading cell (also day-N, 0 = Sunday; the week-number heading also weeknumber)
weeknumber A week-number cell (show-week-numbers)
tbody The table body of weeks
row Each week table row
cell Each day table cell
day Each day button; its state adds day-N (0 = Sunday), selected, today, outside (another month), disabled (before min / after max), disallowed (refused by isDateDisabled), range-start, range-end, in-range, and the names getDayParts returns
today-button The optional "Today" footer button
footer The footer container

CSS custom property

Custom property ค่าเริ่มต้น คำอธิบาย
--ui-calendar-day-radius Corner radius of a day button (default 9999px for circular days)
--ui-calendar-today-dot-radius Corner radius of today's indicator dot (default 50%)
--ui-calendar-day-focus The keyboard focus ring on a day
--ui-calendar-selected-focus Focus ring on a selected day