هيكل التحميل
عنصر نائب يحجز شكل المحتوى أثناء تحميله: أسطر نص، أو دائرة، أو مستطيل، أو بطاقة.
server - 0 KB
هيكل التحميل
server - 0 KBعنصر نائب يحجز شكل المحتوى أثناء تحميله: أسطر نص، أو دائرة، أو مستطيل، أو بطاقة.
جرّبه
variant
rows
الشيفرة
skeleton.tsx
import { Skeleton } from 'topclassui/skeleton'
<div className="max-w-sm">
<Skeleton />
</div>أعطِ الهيكل الأبعاد الحقيقية عبر className؛ تُحصر rows بين 1 و50، والحجم الخاطئ يعني إزاحة في التخطيط.
كل الحالات، بدون تمرير الفأرة
حالة واحدةText
Circle
Rect
Card
أو استورده من الحزمة
topclassui/skeleton
import { Skeleton } from 'topclassui/skeleton'ثبّت مرة واحدة:npm i topclassui@beta zod
أمثلة
- غالبًا ما يكون البديل في
<Suspense>. اختر شكل ما سيأتي عبرvariant:textأوcircleأوrectأوcard. - شكل النص بارتفاع الأسطر التي ينوب عنها عند أي درجة خط، فاضبط درجة الخط عليه كما تضبطها على النص.
- عند وجود أكثر من سطر يكون عرض السطر الأخير ثلثي العرض، كما تنتهي الفقرة.
- تتوقف النبضة عند تفضيل تقليل الحركة.
- تأتي
BadgeوAvatarوButtonوCardوInputوTableوTextareaأيضًا بهيكل تحميل بمقاسها هي تمامًا.
media-object
media-object.tsx
import { Skeleton } from 'topclassui/skeleton'
/** The docs previewer stage: a circle beside three lines, where shrink-0 keeps it round. */
export default function Demo() {
return (
<div className="flex max-w-sm items-center gap-4">
<Skeleton variant="circle" />
<Skeleton />
</div>
)
}
variants
variants.tsx
import { Skeleton } from 'topclassui/skeleton'
/** The four shapes at their own default sizes, in a column the width of a narrow card. */
export default function Demo() {
return (
<div className="flex max-w-sm flex-col gap-6">
<Skeleton />
<Skeleton variant="circle" />
<Skeleton variant="rect" />
<Skeleton variant="card" />
</div>
)
}
rows
rows.tsx
import { Skeleton } from 'topclassui/skeleton'
/** One row stays full width; with more than one, the last is two thirds, like a paragraph's end. */
export default function Demo() {
return (
<div className="grid max-w-2xl grid-cols-3 items-start gap-6">
<Skeleton rows={1} />
<Skeleton />
<Skeleton rows={5} />
</div>
)
}
beside-text
Invoice 2041 was paidon the seventh of Octoberby bank transfer.
Invoice 2041 was paidon the seventh of Octoberby bank transfer.
beside-text.tsx
import { Skeleton } from 'topclassui/skeleton'
/** Three rows beside three lines of real text that never wrap, at two type steps, so a height mismatch shows. */
export default function Demo() {
return (
<div className="flex flex-col gap-8">
<div className="grid max-w-xl grid-cols-2 items-start gap-6 text-sm">
<p className="text-body">
<span className="block truncate">Invoice 2041 was paid</span>
<span className="block truncate">on the seventh of October</span>
<span className="block truncate">by bank transfer.</span>
</p>
<Skeleton rows={3} />
</div>
<div className="grid max-w-xl grid-cols-2 items-start gap-6 text-lg">
<p className="text-body">
<span className="block truncate">Invoice 2041 was paid</span>
<span className="block truncate">on the seventh of October</span>
<span className="block truncate">by bank transfer.</span>
</p>
<Skeleton rows={3} />
</div>
</div>
)
}
custom-size
custom-size.tsx
import { Skeleton } from 'topclassui/skeleton'
/** Real dimensions through className, passed last: the circle's size, the rect's height and width,
* the card's width and radius, and the width and type step of two text rows. */
export default function Demo() {
return (
<div className="flex flex-col gap-6">
<Skeleton variant="circle" className="size-12" />
<Skeleton variant="rect" className="h-control-sm w-32" />
<Skeleton variant="card" className="w-64 rounded-control" />
<Skeleton rows={2} className="w-48 text-lg" />
</div>
)
}
بالعربية، من اليمين إلى اليسار
rtl.tsx
import { Skeleton } from 'topclassui/skeleton'
/** In right to left the circle sits at the right and the short last row starts there too;
* the card below has no side to mirror. */
export default function Demo() {
return (
<div dir="rtl" lang="ar" className="flex max-w-sm flex-col gap-6">
<div className="flex items-center gap-4">
<Skeleton variant="circle" />
<Skeleton />
</div>
<Skeleton variant="card" />
</div>
)
}
الخصائص
لوحة المفاتيح وإمكانية الوصول
لا شيء يُشغَّل: ليس تفاعليًا بمفرده.
- كل شكل يُعرض مع
aria-hidden، فلا يقرأ قارئ الشاشة قائمة من الصناديق الفارغة. - علِّم المنطقة التي تُحمَّل نفسها، مثلًا بـ
aria-busy="true"على العنصر الذي سيملؤه المحتوى.
من اليمين إلى اليسار
تبدأ الأسطر من بداية السطر، فيقع السطر الأخير القصير والدائرة بجانب النص على اليمين في العربية.
الخادم والمتصفح
يُعرض على الخادم ولا يرسل أي JavaScript.
الملفات: index.tsx.
على الشارة: server - 0 KB.