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

مربع نص متعدد الأسطر

مربع نص أصلي يُعرض على الخادم. التمدد التلقائي والعدّاد الحي هما الجزآن الوحيدان اللذان يُحمَّلان في المتصفح.

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

مربع نص متعدد الأسطر

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

مربع نص أصلي يُعرض على الخادم. التمدد التلقائي والعدّاد الحي هما الجزآن الوحيدان اللذان يُحمَّلان في المتصفح.

تثبيت

جرّبه

size
invalid
fullWidth
rows
maxRows
autosize
showCount

الشيفرة

textarea.tsx
import { Textarea } from 'topclassui/textarea'

<div className="grid max-w-sm gap-1">
  <label htmlFor="textarea-playground" className="text-sm font-medium text-body">About you</label>
  <Textarea id="textarea-playground" name="bio" placeholder="Write a short paragraph" />
</div>

وحده هو HTML من الخادم؛ autosize أو showCount هو ما يحمّل نصف العميل الصغير.

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

6 حالات

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

topclassui/textarea
import { Textarea } from 'topclassui/textarea'

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

أمثلة

  • maxLength قيمته 5000 افتراضيًا. مرّر رقمك، أو maxLength={null} لإلغاء الحد؛ عنده يوقف المتصفح الكتابة واللصق.
  • مع autosize تتبع الأسطر النص من rows حتى maxRows، ثم يظهر التمرير. maxRows وحده لا يمدّد شيئًا.
  • يظهر العدّاد بصيغة 42 / 500 تحت الحقل: دائمًا مع showCount، ومع autosize وحده ابتداءً من تسعة أعشار الحد. عند الحد يصبح غامقًا، وهذا ليس خطأ.
  • مع autosize أو showCount يعود العرض إلى صندوق يحيط بالمربع: استخدم fullWidth، أو حدّد عرض الحاوية.
  • بلا أي سكربت يُحفظ ما كُتب ويُرسل، وإعادة ضبط النموذج أصلية.
basic
A short paragraph is enough
autosize
show-count
عدد الأحرف: 12 من 60
عدد الأحرف: 12 من 12
sizes
form
عدد الأحرف: 0 من 5,000
row
عدد الأحرف: 0 من 5,000
عدد الأحرف: 0 من 5,000
long-content
skeleton
بالعربية، من اليمين إلى اليسار
عدد الأحرف: ٢٤ من ٥٠٠

الخصائص

خصائص Textarea
الخاصيةالنوعالافتراضيالحدودالوصف
aria-labelstring--The name read out when no visible label names the control.
aria-labelledbystring--The id of the visible text that names the control.
idstring--The id a <label htmlFor> points at.
autosizebooleanfalse-Grows with the text from rows up to maxRows once the page has hydrated; loads the small client half.
fullWidthbooleanfalse-Stretches the textarea, and the box around it with autosize or showCount, to the width of its container.
invalidbooleanfalse-Marks the value as wrong: sets aria-invalid, and the border turns to danger and thickens.
maxLengthunknown5000-The character cap: your number, 5000 by default, or null for none; clamped to 0-2147483647 and rounded down.
maxRowsinteger, min 1, max 406min 1, max 40With autosize, the most lines it grows to before it scrolls; clamped to 1-40 and never under rows.
rowsinteger, min 1, max 403min 1, max 40The lines it shows, and the least it shrinks to with autosize; clamped to 1-40.
showCountbooleanfalse-Always shows the count against the cap under the field; with autosize alone it shows from nine tenths of it.
sizexs | sm | md | lg | xl | custom"md"-The shared control scale: the padding and the type step. custom emits no size classes.

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

لوحة مفاتيح Textarea
المفاتيحما يفعله
Tabينقل التركيز إلى الحقل، ثم إلى العنصر التالي.
Enterيبدأ سطرًا جديدًا، ولا يرسل النموذج أبدًا.
  • الاسم مطلوب: تسمية <label htmlFor> تشير إلى id، أو aria-label، أو aria-labelledby.
  • العدّاد هو وصف الحقل، فيقرؤه قارئ الشاشة بعد الاسم. وهو ليس منطقة إعلان حيّة.
  • invalid يضبط aria-invalid، ويتحوّل الإطار إلى لون الخطر ويزداد سمكًا.

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

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

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

يُعرض على الخادم، والجزء التفاعلي مكوّن متصفح لا يُرسل إلا عند استخدامه.

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

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