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

شريط تمرير

قيمة واحدة أو نطاق من قيمتين. مفاتيح الأسهم والضغط على المسار يصلان إلى النتيجة نفسها التي يصل إليها السحب.

client - الحجم لم يُقَس بعد

شريط تمرير

client - الحجم لم يُقَس بعد

قيمة واحدة أو نطاق من قيمتين. مفاتيح الأسهم والضغط على المسار يصلان إلى النتيجة نفسها التي يصل إليها السحب.

تثبيت

جرّبه

size
invalid
fullWidth
showValue
min
max
step
largeStep
minStepsBetweenValues

الشيفرة

slider.tsx
import { Slider } from 'topclassui/slider'

<div className="grid justify-items-start gap-2">
  <span id="slider-playground-label" className="text-sm text-body">Volume</span>
  <Slider aria-labelledby="slider-playground-label" defaultValue={60} />
</div>

حقل نطاق مخفي يحمل القيمة، فيُرسل الشريط مع نموذجه؛ ويتحرك المقبض بعد ترطيب الصفحة.

كل الحالات، بدون تمرير الفأرة

4 حالات

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

topclassui/slider
import { Slider } from 'topclassui/slider'

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

أمثلة

  • لرقم يُختار بالإحساس ضمن حدود معروفة. أما الرقم الدقيق فمكانه NumberField.
  • min وmax وstep قيمها 0 و100 و1، ومحصورة بين سالب وموجب 1e15؛ وlargeStep لا يقل عن step، فيتحرك Page Up دائمًا.
  • minStepsBetweenValues يبقي مقبضي النطاق متباعدين؛ فلا يتقاطعان أبدًا.
  • showValue يكتب القيمة بعد المسار، بلغة المزوّد وأرقامه. والقيمة الطويلة تنتقل إلى أسفل المسار.
  • العرض هو عرض Input بنفس size؛ وfullWidth يملأ الحاوية. للشريط قيمة دائمًا، لذا يُقبل required ثم يُهمل.
basic
Volume
range
Price
show-value
40
‏200 US$ – ‏800 US$
form
Volume
sizes
بالعربية، من اليمين إلى اليسار
مستوى الصوت
30
نطاق السعر

الخصائص

خصائص Slider
الخاصيةالنوعالافتراضيالحدودالوصف
aria-labelstring--The name read out when no visible text names the group.
aria-labelledbystring--The id of the visible text that names the group.
classNamestring--Merged last, so a consumer class wins a conflict with the slider's own.
fullWidthbooleanfalse-Fills its parent instead of taking the width of an Input of its size.
invalidbooleanfalse-Marks the value as wrong: sets aria-invalid on the group and on each range input, and the fill, the knob and the line around the track turn to danger.
largeStepnumber, min 0.000001, max 100000000000000010min 0.000001, max 1000000000000000What Page Up, Page Down and Shift with an arrow move; clamped to at least the step, so they always move.
maxnumber, min -1000000000000000, max 1000000000000000100min -1000000000000000, max 1000000000000000The highest value; clamped to plus or minus 1e15.
minnumber, min -1000000000000000, max 10000000000000000min -1000000000000000, max 1000000000000000The lowest value, and the value of a slider with no default; clamped to plus or minus 1e15.
minStepsBetweenValuesnumber, min 0, max 10000000000000000min 0, max 1000000000000000The fewest steps between the two thumbs of a range; clamped to at least 0, so the thumbs never cross.
refRef<HTMLDivElement>--The root element, the <div role="group">.
requiredboolean--Accepted so a Field can spread its object, and dropped: Base UI has none, and a slider always has a value.
showValuebooleanfalse-Writes the value after the track, in the locale and the digits of the provider.
sizexs | sm | md | lg | xl | custom"md"-The scale of the track and the knob, and the width of an Input of that size; custom emits no size classes.
stepnumber, min 0.000001, max 10000000000000001min 0.000001, max 1000000000000000What one arrow key moves; clamped to at least 0.000001, since a step of 0 would never move.

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

لوحة مفاتيح Slider
المفاتيحما يفعله
Tabينقل التركيز إلى مقبض؛ وكل مقبض في النطاق محطة Tab.
ArrowRightArrowUpيضيفان خطوة واحدة.
ArrowLeftArrowDownينقصان خطوة واحدة.
PageUpPageDownيحرّكان بمقدار الخطوة الكبيرة، 10 افتراضيًا؛ وكذلك Shift مع سهم.
HomeEndينتقلان إلى الحد الأدنى والحد الأقصى، أو إلى المقبض الآخر في النطاق.
  • سمِّه بـaria-label أو aria-labelledby: ما يأخذ التركيز هو حقل نطاق داخل المقبض. ويُسمّى مقبضا النطاق «الحد الأدنى» و«الحد الأقصى».
  • لكل سحب طريق بلوحة المفاتيح (WCAG 2.5.7). والمقبض هو الهدف: 24px، و44px تحت مؤشر لمس.
  • invalid يضبط aria-invalid على المجموعة وعلى كل حقل نطاق؛ ويتحوّل الملء والمقبض والخط حول المسار إلى لون الخطر.

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

تحت TopClassProvider باتجاه من اليمين إلى اليسار يبدأ المسار من اليمين: ArrowLeft يضيف خطوة، والقيمة 30 تقع على بعد 30% من اليمين.

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

مكوّن متصفح: يُعرض على الخادم ثم يُرطَّب في المتصفح.

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

على الشارة: client - الحجم لم يُقَس بعد.