حقل نصي

TextInput

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

يدير TextInput تسميته وربطها بالحقل. استخدم helperText وerrorMessage للحالات، وstartAdornment/endAdornment لأيقونة أو وحدة داخل الحقل.

متى تستخدمه

استخدم TextInput للقيم النصية القصيرة: الأسماء، العنوان الوطني، أرقام المرجع، والبريد الإلكتروني. استخدم Textarea للنص متعدد الأسطر، NumberInput للقيم الرقمية بأزرار الزيادة، وSearchBox للبحث.

ضع الوحدات ورموز العملة والأيقونات في startAdornment وendAdornment بدلاً من النص النائب، لتبقى ظاهرة بعد الكتابة. استخدم helperText لتوضيح الصيغة، مثل طول رقم الهوية المتوقع.

أمثلة

حقل بتسمية

الإلزام وحالات الخطأ

أنماط التعبئة

بادئة ولاحقة داخل الحقل

الخصائص

الخصائص التي يعرفها TextInput. سمات العنصر الأصلي تمر كما هي.

<TextInput>

الخاصيةالنوعالافتراضيالوصف
size"md" | "lg"
variant"default" | "filled-lighter" | "filled-darker"
labelreact.ReactNodeVisible field label, auto-associated to the input via htmlFor/id.
helperTextreact.ReactNodeHint shown below the field. Hidden while an error message is showing.
helperIconreact.ReactNode
errorMessagereact.ReactNodeMessage shown below the field when error is true.
errorbooleanMarks the field invalid: sets aria-invalid and error styling.
startAdornmentreact.ReactNodeContent rendered inside the field, before the input (icon, TextInputAffix, or short text). Not aria-hidden (may be interactive); mark purely-decorative icons aria-hidden yourself.
endAdornmentreact.ReactNodeContent rendered inside the field, after the input. Compose a clear button or password-reveal toggle here with <Button size="icon-sm">, the 28px in-field icon size that fits without overflow.

<TextInputAffix>

الخاصيةالنوعالافتراضيالوصف
variant"solid" | "subtle"solid = the SDGA gray prefix/suffix chip; subtle = borderless text.

<TextInputDropdown>

الخاصيةالنوعالافتراضيالوصف
variant"solid" | "subtle"solid = the SDGA gray dropdown chip; subtle = transparent.
iconreact.ReactNodeLeading badge icon (e.g. <BadgeCheck />), sized 24/20 to the field.
selectedbooleanOpen/selected - paints the SDGA dark #384250 chip + white text.

<FieldMessage>

الخاصيةالنوعالافتراضيالوصف
idإلزاميstring
variantإلزامي"error" | "helper"error announces politely; helper is static.
iconreact.ReactNodeOptional 16px leading feedback icon (SDGA helper/error glyph).
childrenإلزاميreact.ReactNode

إمكانية الوصول

ترتبط التسمية label بالحقل عبر htmlFor وid. لذا يركز النقر عليها الحقل، ويعلنها قارئ الشاشة. يرتبط helperText وerrorMessage بالحقل عبر aria-describedby، ويضبط error السمة aria-invalid. يعلن قارئ الشاشة الحقول الإلزامية بأنها إلزامية.

لا تجعل النص النائب التسمية الوحيدة. يختفي النص النائب عند الكتابة، ولا يحقق متطلبات التباين.