Skeleton
Skeleton คือแถบสีเทาในรูปร่างของเนื้อหาที่จะมา แสดงระหว่างที่หน้าโหลดข้อมูลครั้งแรก <ui-skeleton> วาดบรรทัดข้อความ หัวข้อ ช่องกรอก ปุ่ม หรือบล็อก component ส่วนใหญ่ก็มี skeleton element ของตัวเองด้วย ดูรายการทั้งหมดที่ท้ายหน้า
HTMLReactReact + Tailwind<div aria-busy="true" style="display: grid; gap: 16px; max-width: 480px">
<ui-skeleton shape="heading"></ui-skeleton>
<ui-skeleton lines="3"></ui-skeleton>
<ui-skeleton shape="field"></ui-skeleton>
<ui-skeleton shape="button"></ui-skeleton>
</div>
<div aria-busy="true">
<UiSkeleton shape="heading" />
<UiSkeleton lines={3} />
<UiSkeleton shape="field" />
<UiSkeleton shape="button" />
</div>
<div aria-busy="true">
<Skeleton shape="heading" />
<Skeleton lines={3} />
<Skeleton shape="field" />
<Skeleton shape="button" />
</div>
ติดตั้ง
npmshadcn · Web componentshadcn · React + Tailwindคัดลอกเองnpm install @purpurabog/ui
npx shadcn@4 add @kanok-ui/skeleton @kanok-ui/accordion @kanok-ui/big-number @kanok-ui/breadcrumb @kanok-ui/button @kanok-ui/checkbox @kanok-ui/code-snippet @kanok-ui/date-picker @kanok-ui/dropdown @kanok-ui/file-uploader @kanok-ui/number-input @kanok-ui/progress-indicator @kanok-ui/radio @kanok-ui/search @kanok-ui/select @kanok-ui/slider @kanok-ui/structured-list @kanok-ui/table @kanok-ui/tabs @kanok-ui/tag @kanok-ui/text-area @kanok-ui/text-input @kanok-ui/time-picker @kanok-ui/toggle
npx shadcn@4 add @kanok-ui/tw-skeleton
# Web component
# 1. ติดตั้ง dependency
npm install lit@^3.3.0
# 2. คัดลอก "content" ของแต่ละไฟล์จาก
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/skeleton.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/accordion.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/big-number.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/breadcrumb.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/button.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/checkbox.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/code-snippet.json
# 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/dropdown.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/file-uploader.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/number-input.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/progress-indicator.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/radio.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/search.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/select.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/slider.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/structured-list.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/table.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/tabs.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/tag.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/text-area.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/text-input.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/time-picker.json
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/toggle.json
# ไปไว้ที่ target ของมัน:
# components/ui/primitives/skeleton/skeleton.ts
# components/ui/primitives/accordion/accordion-item.ts
# components/ui/primitives/accordion/accordion-skeleton.ts
# components/ui/primitives/accordion/accordion.ts
# components/ui/primitives/big-number/big-number-skeleton.ts
# components/ui/primitives/big-number/big-number.ts
# components/ui/primitives/breadcrumb/breadcrumb-item.ts
# components/ui/primitives/breadcrumb/breadcrumb-skeleton.ts
# components/ui/primitives/breadcrumb/breadcrumb.ts
# components/ui/primitives/button/button-skeleton.ts
# components/ui/primitives/button/button.styles.ts
# components/ui/primitives/button/button.ts
# components/ui/primitives/checkbox/checkbox-group.ts
# components/ui/primitives/checkbox/checkbox-skeleton.ts
# components/ui/primitives/checkbox/checkbox.ts
# components/ui/primitives/code-snippet/code-snippet-skeleton.ts
# components/ui/primitives/code-snippet/code-snippet.ts
# 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/dropdown/dropdown-skeleton.ts
# components/ui/primitives/dropdown/dropdown.styles.ts
# components/ui/primitives/dropdown/dropdown.ts
# components/ui/primitives/file-uploader/file-uploader-item.ts
# components/ui/primitives/file-uploader/file-uploader-shared.ts
# components/ui/primitives/file-uploader/file-uploader-skeleton.ts
# components/ui/primitives/file-uploader/file-uploader.ts
# components/ui/primitives/number-input/number-input-skeleton.ts
# components/ui/primitives/number-input/number-input.styles.ts
# components/ui/primitives/number-input/number-input.ts
# components/ui/primitives/progress-indicator/progress-indicator-skeleton.ts
# components/ui/primitives/progress-indicator/progress-indicator.ts
# components/ui/primitives/progress-indicator/progress-step.ts
# components/ui/primitives/radio/radio-group.ts
# components/ui/primitives/radio/radio-shared.ts
# components/ui/primitives/radio/radio-skeleton.ts
# components/ui/primitives/radio/radio.ts
# components/ui/primitives/search/search-skeleton.ts
# components/ui/primitives/search/search.styles.ts
# components/ui/primitives/search/search.ts
# components/ui/primitives/select/select-skeleton.ts
# components/ui/primitives/select/select.styles.ts
# components/ui/primitives/select/select.ts
# components/ui/primitives/slider/slider-skeleton.ts
# components/ui/primitives/slider/slider.styles.ts
# components/ui/primitives/slider/slider.ts
# components/ui/primitives/structured-list/structured-list-cell.ts
# components/ui/primitives/structured-list/structured-list-row.ts
# components/ui/primitives/structured-list/structured-list-skeleton.ts
# components/ui/primitives/structured-list/structured-list.ts
# components/ui/primitives/table/defs.ts
# components/ui/primitives/table/table-batch-actions.ts
# components/ui/primitives/table/table-body.ts
# components/ui/primitives/table/table-cell.ts
# components/ui/primitives/table/table-column-resize.ts
# components/ui/primitives/table/table-column-settings.ts
# components/ui/primitives/table/table-column.styles.ts
# components/ui/primitives/table/table-csv-export.ts
# components/ui/primitives/table/table-expanded-row.ts
# components/ui/primitives/table/table-grid.ts
# components/ui/primitives/table/table-head.ts
# components/ui/primitives/table/table-header-cell.ts
# components/ui/primitives/table/table-header-description.ts
# components/ui/primitives/table/table-header-row.ts
# components/ui/primitives/table/table-header-title.ts
# components/ui/primitives/table/table-row.ts
# components/ui/primitives/table/table-skeleton.ts
# components/ui/primitives/table/table-toolbar-action.styles.ts
# components/ui/primitives/table/table-toolbar-content.ts
# components/ui/primitives/table/table-toolbar-search.ts
# components/ui/primitives/table/table-toolbar.ts
# components/ui/primitives/table/table.styles.ts
# components/ui/primitives/table/table.ts
# components/ui/primitives/tabs/tab-panel.ts
# components/ui/primitives/tabs/tab.ts
# components/ui/primitives/tabs/tabs-skeleton.ts
# components/ui/primitives/tabs/tabs.styles.ts
# components/ui/primitives/tabs/tabs.ts
# components/ui/primitives/tag/tag-skeleton.ts
# components/ui/primitives/tag/tag.ts
# components/ui/primitives/text-area/text-area-skeleton.ts
# components/ui/primitives/text-area/text-area.ts
# components/ui/primitives/text-input/text-input-skeleton.ts
# components/ui/primitives/text-input/text-input.styles.ts
# components/ui/primitives/text-input/text-input.ts
# components/ui/primitives/time-picker/time-picker-select.ts
# components/ui/primitives/time-picker/time-picker-shared.ts
# components/ui/primitives/time-picker/time-picker-skeleton.ts
# components/ui/primitives/time-picker/time-picker.ts
# components/ui/primitives/toggle/toggle-skeleton.ts
# components/ui/primitives/toggle/toggle.ts
# 3. ทำแบบเดียวกันกับ item ที่มันใช้ (registry/<name>.json):
# shared-element, shared-skeleton, tokens, shared-events, shared-field, core-big-number, shared-localize, tooltip, core-overflow, menu, overflow-menu, shared-navigate, core-button, shared-form-control, shared-slots, copy-button, core-code-snippet, shared-align, calendar, core-date, core-overlay, core-popup, core-sheet, shared-position, shared-quiet-focus, core-dropdown, core-listbox, core-typeahead, shared-listbox, core-file-uploader, progress-bar, core-number-format, shared-affixes, core-roving, core-slider, shared-row-wrap, core-column-resize, core-csv, core-grid, core-table, pagination, popover, layer, core-auto-grow, core-field, core-mask
# React + Tailwind
# 1. ติดตั้ง dependency
# (ไม่มี)
# 2. คัดลอก "content" ของแต่ละไฟล์จาก
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/tw-skeleton.json
# ไปไว้ที่ target ของมัน:
# components/ui/react-tw/skeleton.tsx
# 3. ทำแบบเดียวกันกับ item ที่มันใช้ (registry/<name>.json):
# tw-field, tw-theme, tw-utils
npm ให้ทุก component จากแพ็กเกจ ส่วน shadcn คัดลอกซอร์สเข้าแอปของคุณแทน เป็นสำเนาที่ล็อกเวอร์ชันนี้และแก้เองได้ คำสั่ง shadcn ต้องตั้ง registry @kanok-ui ใน components.json ครั้งเดียวก่อน ดู ติดตั้ง
วิธีใช้
HTMLReactReact + Tailwind<script type="module">import '@purpurabog/ui/skeleton';</script>
<ui-skeleton lines="2"></ui-skeleton>
import { UiSkeleton } from '@purpurabog/ui/react';
<UiSkeleton lines={2} />
import { Skeleton } from '@/components/ui/react-tw/skeleton';
<Skeleton lines={2} />
Skeleton หรือ loading?
ใช้ skeleton ตอนหน้าโหลดครั้งแรก เมื่อรู้ layout ของสิ่งที่จะมา: หน้าปรากฏทันทีแล้วเนื้อหาค่อยเติมเข้ามา ใช้ Loading หรือ Inline loading เมื่อผู้ใช้รอผลของการกระทำ เช่น การบันทึก ซึ่ง skeleton จะไปบังสิ่งที่เขากำลังทำอยู่
บรรทัดข้อความ
shape="text" (ค่าเริ่มต้น) วาดแถบ lines เส้น ค่าเริ่มต้น 3 เส้น ถ้ามีหลายเส้น เส้นสุดท้ายจะสั้นกว่า ให้ดูเหมือนย่อหน้า
HTMLReactReact + Tailwind<div style="display: grid; gap: 24px; max-width: 480px">
<ui-skeleton lines="1"></ui-skeleton>
<ui-skeleton lines="4"></ui-skeleton>
</div>
<UiSkeleton lines={1} />
<UiSkeleton lines={4} />
<Skeleton lines={1} />
<Skeleton lines={4} />
หัวข้อ
shape="heading" คือแถบเดียวสูง 24px กว้างครึ่งหนึ่งโดยค่าเริ่มต้น
HTMLReactReact + Tailwind<div style="display: grid; gap: 16px; max-width: 480px">
<ui-skeleton shape="heading"></ui-skeleton>
<ui-skeleton lines="2"></ui-skeleton>
</div>
<UiSkeleton shape="heading" />
<UiSkeleton lines={2} />
<Skeleton shape="heading" />
<Skeleton lines={2} />
ช่องกรอกและปุ่ม
shape="field" คือแถบ label สั้น ๆ เหนือแถบช่องกรอกสูง 48px shape="button" คือแถบสูง 48px กว้าง 120px วางเรียงในบรรทัด ถ้าเป็นช่องกรอกหรือปุ่มจริง ให้ใช้ skeleton element ของมันเอง (ดูรายการด้านล่าง) ซึ่งขนาดตรงกัน
HTMLReactReact + Tailwind<div style="display: grid; gap: 16px; max-width: 480px">
<ui-skeleton shape="field"></ui-skeleton>
<ui-skeleton shape="field"></ui-skeleton>
<div style="display: flex; flex-wrap: wrap; gap: 16px; align-items: center">
<ui-skeleton shape="button"></ui-skeleton>
<ui-skeleton shape="button"></ui-skeleton>
</div>
</div>
<UiSkeleton shape="field" />
<UiSkeleton shape="field" />
<UiSkeleton shape="button" />
<UiSkeleton shape="button" />
<Skeleton shape="field" />
<Skeleton shape="field" />
<Skeleton shape="button" />
<Skeleton shape="button" />
บล็อกแทนที่
shape="block" คือแถบเดียว สูง 160px โดยค่าเริ่มต้น สำหรับรูปภาพ กราฟ หรือการ์ดทั้งใบ (SkeletonPlaceholder ของ Carbon) ตั้งความสูงด้วย CSS property --ui-skeleton-height (height ใน React + Tailwind)
HTMLReactReact + Tailwind<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; max-width: 520px">
<ui-skeleton shape="block"></ui-skeleton>
<ui-skeleton shape="block" style="--ui-skeleton-height: 96px"></ui-skeleton>
</div>
<UiSkeleton shape="block" />
<UiSkeleton shape="block" style={{ '--ui-skeleton-height': '96px' } as CSSProperties} />
<Skeleton shape="block" />
<Skeleton shape="block" height="96px" />
ความกว้าง
ทุกรูปร่างกว้างเต็มโดยค่าเริ่มต้น (หัวข้อครึ่งหนึ่ง ปุ่ม 120px) ตั้งความกว้างด้วย CSS property --ui-skeleton-width (width ใน React + Tailwind) ให้ดูเหมือนเนื้อหาที่จะมา ใส่ค่าพร้อมหน่วย ("200px", "70%") เพราะ width และ height รับเป็นข้อความ เหมือน width ของ SkeletonText ใน Carbon
HTMLReactReact + Tailwind<div style="display: grid; gap: 16px; max-width: 480px">
<ui-skeleton shape="heading" style="--ui-skeleton-width: 200px"></ui-skeleton>
<ui-skeleton lines="1" style="--ui-skeleton-width: 70%"></ui-skeleton>
<ui-skeleton shape="button" style="--ui-skeleton-width: 160px"></ui-skeleton>
</div>
<UiSkeleton shape="heading" style={{ '--ui-skeleton-width': '200px' } as CSSProperties} />
<UiSkeleton lines={1} style={{ '--ui-skeleton-width': '70%' } as CSSProperties} />
<UiSkeleton shape="button" style={{ '--ui-skeleton-width': '160px' } as CSSProperties} />
<Skeleton shape="heading" width="200px" />
<Skeleton lines={1} width="70%" />
<Skeleton shape="button" width="160px" />
ใน React + Tailwind ให้ใส่ width และ height เป็น string พร้อมหน่วย เพราะมันตั้ง CSS property และตัวเลขเปล่า ๆ จะไม่มีหน่วย
สลับเป็นเนื้อหา
skeleton ถูกซ่อนจาก screen reader ให้บอกเรื่องการโหลดที่ container แทน: aria-busy="true" ระหว่างโหลด และข้อความสถานะสั้น ๆ เมื่อข้อมูลมาถึง ใส่เนื้อหาเข้าไปแทนแล้วเอาทั้งสองออก
กำลังโหลดข้อมูลผู้ขาย…
โหลดอีกครั้ง
HTMLReactReact + Tailwind<div id="skeleton-card" aria-busy="true" style="display: grid; gap: 16px; max-width: 480px; padding: 16px; border: 1px solid var(--ui-hairline)">
<ui-skeleton shape="heading"></ui-skeleton>
<ui-skeleton lines="2"></ui-skeleton>
<ui-skeleton shape="button"></ui-skeleton>
</div>
<p id="skeleton-card-status" role="status">กำลังโหลดข้อมูลผู้ขาย…</p>
<ui-button id="skeleton-card-reload" kind="tertiary">โหลดอีกครั้ง</ui-button>
<script type="module">
const card = document.getElementById('skeleton-card');
const status = document.getElementById('skeleton-card-status');
const skeleton = card.innerHTML;
const content = `
<h4 style="margin: 0">บริษัท สยามโลจิสติกส์ จำกัด</h4>
<p style="margin: 0">เลขประจำตัวผู้เสียภาษี 0105556000000 · สัญญาที่ใช้งาน 3 ฉบับ · ชำระตรงเวลามา 24 เดือน</p>
<div><ui-button kind="secondary">ดูสัญญา</ui-button></div>`;
let timer;
const load = () => {
clearTimeout(timer);
card.innerHTML = skeleton;
card.setAttribute('aria-busy', 'true');
status.textContent = 'กำลังโหลดข้อมูลผู้ขาย…';
timer = setTimeout(() => {
card.innerHTML = content;
card.removeAttribute('aria-busy');
status.textContent = 'โหลดข้อมูลผู้ขายแล้ว';
}, 2000);
};
document.getElementById('skeleton-card-reload').addEventListener('click', load);
load();
</script>
<div aria-busy={loading || undefined}>
{loading ? (
<>
<UiSkeleton shape="heading" />
<UiSkeleton lines={2} />
<UiSkeleton shape="button" />
</>
) : (
<VendorCard vendor={vendor} />
)}
</div>
<p role="status">{loading ? 'กำลังโหลดข้อมูลผู้ขาย…' : 'โหลดข้อมูลผู้ขายแล้ว'}</p>
<div aria-busy={loading || undefined}>
{loading ? (
<>
<Skeleton shape="heading" />
<Skeleton lines={2} />
<Skeleton shape="button" />
</>
) : (
<VendorCard vendor={vendor} />
)}
</div>
<p role="status">{loading ? 'กำลังโหลดข้อมูลผู้ขาย…' : 'โหลดข้อมูลผู้ขายแล้ว'}</p>
VendorCard แทน component ของคุณเอง
Skeleton ของ component
component ส่วนใหญ่มี skeleton element ในรูปร่างและขนาดของมันเอง เหมือน TextInputSkeleton, DropdownSkeleton ฯลฯ ของ Carbon แต่ละตัว import แยก @purpurabog/ui/<component>-skeleton แต่ละตัวมี wrapper ของ React ชื่อตาม element ใน @purpurabog/ui/react (UiTextInputSkeleton, UiDropdownSkeleton …) React + Tailwind มี component …Skeleton อยู่คู่กับแต่ละ component
HTMLReactReact + Tailwind<div aria-busy="true" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 32px 24px">
<ui-text-input-skeleton></ui-text-input-skeleton>
<ui-dropdown-skeleton></ui-dropdown-skeleton>
<ui-date-picker-skeleton range></ui-date-picker-skeleton>
<ui-search-skeleton></ui-search-skeleton>
<ui-slider-skeleton></ui-slider-skeleton>
<div style="display: flex; gap: 16px; align-items: center"><ui-button-skeleton></ui-button-skeleton><ui-tag-skeleton></ui-tag-skeleton></div>
<div style="display: grid; gap: 12px"><ui-checkbox-skeleton></ui-checkbox-skeleton><ui-radio-skeleton></ui-radio-skeleton><ui-toggle-skeleton></ui-toggle-skeleton></div>
<ui-breadcrumb-skeleton></ui-breadcrumb-skeleton>
<ui-tabs-skeleton tabs="3"></ui-tabs-skeleton>
<ui-progress-indicator-skeleton steps="3"></ui-progress-indicator-skeleton>
</div>
import { UiTextInputSkeleton, UiDropdownSkeleton, UiButtonSkeleton, UiTagSkeleton } from '@purpurabog/ui/react';
<div aria-busy="true">
<UiTextInputSkeleton />
<UiDropdownSkeleton />
<UiButtonSkeleton />
<UiTagSkeleton />
</div>
import { TextInputSkeleton } from '@/components/ui/react-tw/text-input';
import { DropdownSkeleton } from '@/components/ui/react-tw/dropdown';
import { ButtonSkeleton } from '@/components/ui/react-tw/button';
import { TagSkeleton } from '@/components/ui/react-tw/tag';
<div aria-busy="true">
<TextInputSkeleton />
<DropdownSkeleton />
<ButtonSkeleton />
<TagSkeleton />
</div>
Skeleton ของช่องกรอกแบบ fluid
skeleton ของช่องกรอกรับ fluid สำหรับ skeleton ของช่องกรอกแบบ fluid: กล่องสูง 64px ที่มีแถบสองเส้น ใน <ui-fluid-form> (FluidForm ใน React + Tailwind) จะเป็น fluid โดยไม่ต้องใส่ attribute skeleton ของ time picker เป็น fluid เสมอ เพราะ Carbon มีแค่แบบนั้น
HTMLReactReact + Tailwind<div aria-busy="true" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 32px 24px">
<ui-text-input-skeleton fluid></ui-text-input-skeleton>
<ui-select-skeleton fluid></ui-select-skeleton>
<ui-date-picker-skeleton fluid></ui-date-picker-skeleton>
<ui-time-picker-skeleton></ui-time-picker-skeleton>
</div>
import { UiTextInputSkeleton, UiSelectSkeleton, UiDatePickerSkeleton, UiTimePickerSkeleton } from '@purpurabog/ui/react';
<UiTextInputSkeleton fluid />
<UiSelectSkeleton fluid />
<UiDatePickerSkeleton fluid />
<UiTimePickerSkeleton />
<TextInputSkeleton fluid />
<SelectSkeleton fluid />
<DatePickerSkeleton fluid />
<TimePickerSkeleton />
Skeleton ของทุก component
หน้าของแต่ละ component แสดง skeleton พร้อมตัวเลือกของมัน skeleton ของช่องกรอก (text input, number input, dropdown, select, date picker) รับ size (sm, md, lg), hide-label และ fluid ด้วย
| Element |
React + Tailwind |
Attribute |
หน้า |
ui-accordion-skeleton |
AccordionSkeleton |
count, open, alignment |
Accordion |
ui-big-number-skeleton |
BigNumberSkeleton |
size |
Big number |
ui-breadcrumb-skeleton |
BreadcrumbSkeleton |
items, no-trailing-slash, size |
Breadcrumb |
ui-button-skeleton |
ButtonSkeleton |
size |
Button |
ui-checkbox-skeleton |
CheckboxSkeleton |
|
Checkbox |
ui-code-snippet-skeleton |
CodeSnippetSkeleton |
type |
Code snippet |
ui-date-picker-skeleton |
DatePickerSkeleton |
range |
Date picker |
ui-dropdown-skeleton |
DropdownSkeleton |
|
Dropdown ใช้กับ combobox และ multi-select ด้วย |
ui-file-uploader-skeleton |
FileUploaderSkeleton |
|
File uploader |
ui-number-input-skeleton |
NumberInputSkeleton |
|
Number input |
ui-progress-indicator-skeleton |
ProgressIndicatorSkeleton |
steps, vertical |
Progress indicator |
ui-radio-skeleton |
RadioSkeleton |
|
Radio |
ui-search-skeleton |
SearchSkeleton |
size, fluid |
Search |
ui-select-skeleton |
SelectSkeleton |
|
Select |
ui-slider-skeleton |
SliderSkeleton |
hide-label, two-handles |
Slider |
ui-structured-list-skeleton |
StructuredListSkeleton |
rows |
Structured list |
ui-table-skeleton |
DataTableSkeleton |
row-count, column-count, zebra, show-header, show-toolbar |
Data table |
ui-tabs-skeleton |
TabsSkeleton |
tabs |
Tabs |
ui-tag-skeleton |
TagSkeleton |
size |
Tag |
ui-text-area-skeleton |
TextAreaSkeleton |
hide-label, fluid |
Text area |
ui-text-input-skeleton |
TextInputSkeleton |
|
Text input |
ui-time-picker-skeleton |
TimePickerSkeleton |
is-only-two |
Time picker |
ui-toggle-skeleton |
ToggleSkeleton |
|
Toggle |
ui-table-skeleton มากับ @purpurabog/ui/table ทุก element ในตารางนี้มี wrapper ของ React ชื่อตาม element เช่น ui-accordion-skeleton คือ UiAccordionSkeleton และ ui-table-skeleton คือ UiTableSkeleton prop ของมันคือ attribute ที่เขียนแบบ camelCase (hideLabel, noTrailingSlash) ใน React + Tailwind ให้ import …Skeleton จากไฟล์ของ component นั้น เช่น TextInputSkeleton จาก @/components/ui/react-tw/text-input ส่วน RadioSkeleton มาจาก radio-group
Accessibility
- skeleton ทุกตัวถูกซ่อนจาก screen reader (
aria-hidden) และไม่รับโฟกัส
- บอก "กำลังโหลด" ที่ container:
aria-busy="true" และข้อความสถานะสั้น ๆ เช่น role="status" "กำลังโหลดสัญญา…" แล้วเอาทั้งสองออกเมื่อเนื้อหามาถึง
- แถบมีแสงวิ่ง 3 วินาทีแบบ Carbon เมื่อผู้ใช้ตั้ง
prefers-reduced-motion จะหยุดวิ่ง
API
สร้างจากแพ็กเกจโดยตรง ใน React ส่ง property เป็น prop ชื่อเดียวกัน ส่วน event ก็เป็น prop เช่นกัน (ดูคอลัมน์ React)
<ui-skeleton> · React UiSkeleton
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
shape |
shape |
SkeletonShape |
'text' |
|
lines |
lines |
number |
3 |
Number of lines for shape="text". |
CSS part
| Part |
คำอธิบาย |
bone |
Each grey placeholder bar |
label |
The short label bar of shape="field" |
CSS custom property
| Custom property |
ค่าเริ่มต้น |
คำอธิบาย |
--ui-skeleton-width |
|
Width (default: full width; buttons 120px) |
--ui-skeleton-height |
|
Height of shape="block" (default 160px) |
<ui-accordion-skeleton> · React UiAccordionSkeleton
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
count |
count |
number |
4 |
|
open |
open |
boolean |
true |
The first item shows its content. |
alignment |
alignment |
'start' | 'end' |
'end' |
|
CSS part
| Part |
คำอธิบาย |
title |
Each title bar |
line |
Each line of the open item |
<ui-big-number-skeleton> · React UiBigNumberSkeleton
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
size |
size |
BigNumberSize |
'default' |
|
CSS part
| Part |
คำอธิบาย |
label |
The label bar |
value |
The value bar |
<ui-breadcrumb-skeleton> · React UiBreadcrumbSkeleton
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
items |
items |
number |
3 |
|
no-trailing-slash |
noTrailingSlash |
boolean |
false |
|
size |
size |
'sm' | 'md' |
'md' |
|
CSS part
| Part |
คำอธิบาย |
item |
Each bar |
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
size |
size |
ButtonSize |
'lg' |
|
CSS part
| Part |
คำอธิบาย |
bone |
The bar |
<ui-checkbox-skeleton> · React UiCheckboxSkeleton
CSS part
| Part |
คำอธิบาย |
box |
The empty box |
label |
The label bar |
<ui-code-snippet-skeleton> · React UiCodeSnippetSkeleton
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
type |
type |
'single' | 'multi' |
'single' |
|
CSS part
| Part |
คำอธิบาย |
base |
The box |
line |
Each bar |
<ui-date-picker-skeleton> · React UiDatePickerSkeleton
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
range |
range |
boolean |
false |
Start and end inputs. |
size |
size |
'sm' | 'md' | 'lg' |
'md' |
The field's height: sm 32px, md 40px, lg 48px. |
hide-label |
hideLabel |
boolean |
false |
No label bar (the field had hide-label). |
fluid |
fluid |
boolean |
false |
The fluid field's skeleton (Carbon Fluid*Skeleton): a 64px box with two bars; <ui-fluid-form> sets it. |
CSS part
| Part |
คำอธิบาย |
label |
Each label bar |
field |
Each field bar (fluid: the box) |
<ui-dropdown-skeleton> · React UiDropdownSkeleton
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
size |
size |
'sm' | 'md' | 'lg' |
'md' |
The field's height: sm 32px, md 40px, lg 48px. |
hide-label |
hideLabel |
boolean |
false |
No label bar (the field had hide-label). |
fluid |
fluid |
boolean |
false |
The fluid field's skeleton (Carbon Fluid*Skeleton): a 64px box with two bars; <ui-fluid-form> sets it. |
CSS part
| Part |
คำอธิบาย |
label |
The label bar |
field |
The field bar |
<ui-file-uploader-skeleton> · React UiFileUploaderSkeleton
CSS part
| Part |
คำอธิบาย |
title |
The title bar |
description |
The description bar |
button |
The button bar |
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
size |
size |
'sm' | 'md' | 'lg' |
'md' |
The field's height: sm 32px, md 40px, lg 48px. |
hide-label |
hideLabel |
boolean |
false |
No label bar (the field had hide-label). |
fluid |
fluid |
boolean |
false |
The fluid field's skeleton (Carbon Fluid*Skeleton): a 64px box with two bars; <ui-fluid-form> sets it. |
CSS part
| Part |
คำอธิบาย |
label |
The label bar |
field |
The field bar |
<ui-progress-indicator-skeleton> · React UiProgressIndicatorSkeleton
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
steps |
steps |
number |
4 |
|
vertical |
vertical |
boolean |
false |
|
CSS part
| Part |
คำอธิบาย |
step |
Each step |
label |
Each label bar |
<ui-radio-skeleton> · React UiRadioSkeleton
CSS part
| Part |
คำอธิบาย |
label |
The label bar |
<ui-search-skeleton> · React UiSearchSkeleton
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
size |
size |
'sm' | 'md' | 'lg' |
'md' |
|
fluid |
fluid |
boolean |
false |
Carbon FluidSearchSkeleton. |
CSS part
| Part |
คำอธิบาย |
field |
The bar (fluid: the box) |
label |
Fluid: the 25% bar |
value |
Fluid: the 50% bar |
<ui-select-skeleton> · React UiSelectSkeleton
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
size |
size |
'sm' | 'md' | 'lg' |
'md' |
The field's height: sm 32px, md 40px, lg 48px. |
hide-label |
hideLabel |
boolean |
false |
No label bar (the field had hide-label). |
fluid |
fluid |
boolean |
false |
The fluid field's skeleton (Carbon Fluid*Skeleton): a 64px box with two bars; <ui-fluid-form> sets it. |
CSS part
| Part |
คำอธิบาย |
label |
The label bar |
field |
The field bar |
<ui-slider-skeleton> · React UiSliderSkeleton
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
hide-label |
hideLabel |
boolean |
false |
|
two-handles |
twoHandles |
boolean |
false |
The skeleton of a two-thumb slider (<ui-slider value-upper>). |
CSS part
| Part |
คำอธิบาย |
label |
The label bar |
range-label |
The min / max bars |
<ui-structured-list-skeleton> · React UiStructuredListSkeleton
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
rows |
rows |
number |
5 |
|
CSS part
| Part |
คำอธิบาย |
header |
The header bars |
row |
Each empty row |
<ui-table-skeleton> · React UiTableSkeleton
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
column-count |
columnCount |
number |
5 |
|
row-count |
rowCount |
number |
5 |
|
show-header |
showHeader |
boolean |
true |
The title / description bars (Carbon show-header; show-header="false" hides them). |
show-toolbar |
showToolbar |
boolean |
true |
The toolbar bar (Carbon show-toolbar; show-toolbar="false" hides it). |
zebra |
zebra |
boolean |
false |
Stripe every second row. |
Property
| Property |
ชนิด |
คำอธิบาย |
headers |
string[] |
Header texts to show instead of bars (Carbon headers); their number sets the columns. |
CSS part
| Part |
คำอธิบาย |
table |
The <table> |
<ui-tabs-skeleton> · React UiTabsSkeleton
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
tabs |
tabs |
number |
5 |
|
CSS part
| Part |
คำอธิบาย |
tab |
Each tab |
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
size |
size |
'sm' | 'md' | 'lg' |
'md' |
|
CSS part
| Part |
คำอธิบาย |
bone |
The pill |
<ui-text-area-skeleton> · React UiTextAreaSkeleton
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
size |
size |
'sm' | 'md' | 'lg' |
'md' |
The field's height: sm 32px, md 40px, lg 48px. |
hide-label |
hideLabel |
boolean |
false |
No label bar (the field had hide-label). |
fluid |
fluid |
boolean |
false |
The fluid field's skeleton (Carbon Fluid*Skeleton): a 64px box with two bars; <ui-fluid-form> sets it. |
CSS part
| Part |
คำอธิบาย |
label |
The label bar |
field |
The field bar |
<ui-text-input-skeleton> · React UiTextInputSkeleton
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
size |
size |
'sm' | 'md' | 'lg' |
'md' |
The field's height: sm 32px, md 40px, lg 48px. |
hide-label |
hideLabel |
boolean |
false |
No label bar (the field had hide-label). |
fluid |
fluid |
boolean |
false |
The fluid field's skeleton (Carbon Fluid*Skeleton): a 64px box with two bars; <ui-fluid-form> sets it. |
CSS part
| Part |
คำอธิบาย |
label |
The label bar |
field |
The field bar |
<ui-time-picker-skeleton> · React UiTimePickerSkeleton
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
is-only-two |
isOnlyTwo |
boolean |
false |
Two boxes (time and AM / PM), half each. |
CSS part
| Part |
คำอธิบาย |
field |
Each box |
<ui-toggle-skeleton> · React UiToggleSkeleton
CSS part
| Part |
คำอธิบาย |
circle |
The circle |
bar |
The bar |