Skip to content

CSS: skeleton-loader ​

.instui-skeleton-loader — ตัวแสดงตำแหน่งตกแต่งสำหรับเนื้อหาที่ยังโหลดไม่เสร็จ

TIP

การปรับปรุง JS — CSS ของคอมโพเนนต์นี้เรนเดอร์และทำงานได้ด้วยตัวเอง; จับคู่กับ @pantoken/interactions เพื่อเพิ่มพฤติกรรมเชิงโต้ตอบ ดู ตารางตัวปรับแต่งด้านล่าง.

การเข้าถึง ​

Mark the decorative loader aria-hidden="true". ใส่ aria-busy บนส่วนเนื้อหาพาเรนต์, โดยมีสถานะเริ่มต้นว่างและ alert นอกบริเวณนั้น. Use initSkeletonLoading from the interactions package เพื่อประกาศสถานะการโหลดของพาเรนต์ รูปร่างต้องไม่รับโฟกัส.

การใช้งาน ​

css
@import "@pantoken/plugin-custom-components/custom-components.css";

ตัวอย่าง ​

html
<div style="display: flex; align-items: center; gap: 1rem; max-inline-size: 24rem">
  <div class="instui-skeleton-loader -type-avatar" aria-hidden="true">
    <div class="shape"></div>
  </div>
  <div style="flex: 1">
    <div class="instui-skeleton-loader -type-text -size-md" aria-hidden="true">
      <div class="skeleton-row" style="inline-size: 45%"><div class="shape"></div></div>
      <div class="skeleton-row" style="inline-size: 72%"><div class="shape"></div></div>
    </div>
  </div>
</div>

โครงสร้าง ​

text
.instui-skeleton-loader
  .shape
  .skeleton-row (0..n)
    .shape
flowchart TD n0[".instui-skeleton-loader"]:::cssdoc-root n1(".shape"):::cssdoc-part n2(".skeleton-row"):::cssdoc-part n3(".shape"):::cssdoc-part n0 --> n1 n2 --> n3 n0 -->|0..n| n2 classDef cssdoc-root stroke-width:1px; classDef cssdoc-part stroke-width:1px; classDef cssdoc-slot stroke-width:1px; classDef cssdoc-component stroke-width:1px;

ตัวปรับแต่ง ​

ตัวปรับแต่งคำอธิบาย
.-size-lgแถวข้อความขนาดใหญ่.
.-size-mdแถวข้อความขนาดกลาง (ค่าเริ่มต้น).
.-size-smแถวข้อความขนาดเล็ก.
.-size-xlแถวข้อความขนาดใหญ่พิเศษ.
.-size-xsแถวข้อความขนาดเล็กพิเศษ.
.-size-xxlแถวข้อความขนาดใหญ่ที่สุด.
.-size-xxsแถวข้อความขนาด legend.
.-type-avatarตัวแสดงตำแหน่งอวาตาร์ทรงกลม ขนาดกลางเท่านั้น.
.-type-imageตัวแสดงตำแหน่งรูปภาพ ขนาดกลางเท่านั้น.
.-type-textแถบข้อความ (ค่าเริ่มต้น).

ส่วนประกอบ ​

ส่วนคำอธิบาย
.shapeพื้นผิวตัวแสดงตำแหน่งที่ถูกตัดขอบ ปรับขนาดสำหรับประเภทตัวโหลดที่เลือก.
.skeleton-rowตัวห่อหุ้มแถวข้อความแบบซ้ำที่ใช้ระยะห่างแนวตั้ง.

องค์ประกอบเทียม ​

องค์ประกอบเทียมคำอธิบาย
::before—

พร็อพเพอร์ตีที่กำหนดเอง ​

คุณสมบัติชนิดค่าเริ่มต้นคำอธิบาย
--pantoken-skeleton-sweep<percentage>0%—

แอนิเมชัน ​

แอนิเมชันคำอธิบาย
pantoken-skeleton-sweep—

เงื่อนไข ​

ชนิดการค้นหาคำอธิบาย
media(prefers-reduced-motion: reduce)—

โทเค็นที่ใช้ ​

Tokenชนิดค่า
--instui-component-skeleton-loader-avatar-border-radius<length>999rem
--instui-component-skeleton-loader-background-color<color>LightDarklight-dark(#8D959F, #5F6E7A)
--instui-component-skeleton-loader-bezier—0.42, 0, 0.58, 1
--instui-component-skeleton-loader-duration<time>1500ms
--instui-component-skeleton-loader-image-border-radius<length>0.5rem
--instui-component-skeleton-loader-shimmer-color<color>LightDarklight-dark(#AAB0B5, #737F8A)
--instui-component-skeleton-loader-text-border-radius<length>0.25rem
--instui-component-skeleton-loader-text-height-lg<length>1.75rem
--instui-component-skeleton-loader-text-height-md<length>1.5rem
--instui-component-skeleton-loader-text-height-sm<length>1.25rem
--instui-component-skeleton-loader-text-height-xl<length>2rem
--instui-component-skeleton-loader-text-height-xs<length>1rem
--instui-component-skeleton-loader-text-height-xxl<length>2.25rem
--instui-component-skeleton-loader-text-height-xxs<length>0.75rem
--instui-component-skeleton-loader-text-padding-lg<length>0.21875rem
--instui-component-skeleton-loader-text-padding-md<length>0.1875rem
--instui-component-skeleton-loader-text-padding-sm<length>0.15625rem
--instui-component-skeleton-loader-text-padding-xl<length>0.25rem
--instui-component-skeleton-loader-text-padding-xs<length>0.125rem
--instui-component-skeleton-loader-text-padding-xxl<length>0.28125rem
--instui-component-skeleton-loader-text-padding-xxs<length>0.1875rem
--instui-size-interactive-height-md<length>2.5rem
--pantoken-skeleton-height<length>1.5rem
--pantoken-skeleton-padding<length>0.1875rem
--pantoken-skeleton-radius<length>0.25rem