انتقل إلى المحتوى
TopClass UI

المقياس

قراءة داخل نطاق معروف، مثل مساحة القرص أو النتيجة: مسار محايد عليه شريط بلون النبرة، يُعرض على الخادم.

server - 0 KB

المقياس

server - 0 KB

قراءة داخل نطاق معروف، مثل مساحة القرص أو النتيجة: مسار محايد عليه شريط بلون النبرة، يُعرض على الخادم.

تثبيت
Battery

الشيفرة

meter.tsx
import { Meter } from 'topclassui/meter'

/** The docs sample: the visible text names the meter, which reads 60 of 0 to 100. */
export default function Demo() {
  return (
    <div className="grid max-w-sm gap-2">
      <span id="battery-label" className="text-sm">Battery</span>
      <Meter value={60} aria-labelledby="battery-label" />
    </div>
  )
}

لا يعرض أي نص، فسمِّه بـ aria-label أو aria-labelledby؛ والنوع يرفض مقياسًا بلا أيٍّ منهما.

أو استورده من الحزمة

topclassui/meter
import { Meter } from 'topclassui/meter'

ثبّت مرة واحدة:npm i topclassui@beta zod

أمثلة

  • للمهمة التي تتقدم نحو الاكتمال استخدم Progress؛ أما Meter فقراءة، لها min وmax وvalue خاصة بها.
  • min وmax محصوران، وmax يُرفع إلى min حين يقل عنه، وvalue يبقى بينهما.
  • aria-valuetext يمرّ كما هو، فيقول قارئ الشاشة "512 GB of 1 TB" بدل "512".
  • المسار يملأ حاويته ولا يضيق عن 4rem أبدًا؛ أعطه عرضًا خاصًا عبر className.
basic
Battery
range
Disk: 512 GB of 1 TB
tones
sizes
custom-size
بالعربية، من اليمين إلى اليسار
القرص: ٥١٢ غيغابايت من ١ تيرابايت

الخصائص

خصائص Meter
الخاصيةالنوعالافتراضيالحدودالوصف
aria-labelstring--The name read out when no visible text names the meter.
aria-labelledbystring--The id of the visible text that names the meter.
maxnumber, min -1000000000000000, max 1000000000000000100min -1000000000000000, max 1000000000000000The high end of the range, where the track is full; raised to min when below it.
minnumber, min -1000000000000000, max 10000000000000000min -1000000000000000, max 1000000000000000The low end of the range, where the track is empty.
sizexs | sm | md | lg | xl | custom"md"-The shared size scale, which sets the track height; custom emits none.
toneprimary | neutral | success | warning | danger | info"primary"-The colour of the bar; the track stays neutral in every tone.
valuenumber, min -1000000000000000, max 10000000000000000min -1000000000000000, max 1000000000000000The reading, clamped between min and max before it reaches ARIA or the bar.

لوحة المفاتيح وإمكانية الوصول

لا شيء يُشغَّل: ليس تفاعليًا بمفرده.

  • يكتب role="meter" مع الحد الأدنى والحد الأقصى والقيمة بعد حصرها.
  • الشريط يأخذ لون نص النبرة، وإطار line-strong يحدد نهاية النطاق. وتحت الألوان القسرية يكون المسار Canvas والشريط CanvasText.

من اليمين إلى اليسار

الشريط ينمو من بداية السطر: من اليمين في العربية، دون صنف خاص بذلك.

الخادم والمتصفح

يُعرض على الخادم ولا يرسل أي JavaScript.

الملفات: index.tsx.

على الشارة: server - 0 KB.