قائمة منسدلة

Dropdown

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

يتكون حقل الاختيار Dropdown من عناصر DropdownItem. أضف multiple للاختيار المتعدد، أو searchable لإضافة بحث داخل اللوحة.

متى تستخدمه

استخدم Dropdown حين يحتاج حقل الاختيار إلى بحث أو قيم متعددة أو خيارات مجمعة: اختيار عدة خدمات، أو التصفية بحسب مدن كثيرة، أو الاختيار من قائمة مرجعية طويلة. استخدم Select للاختيار المفرد البسيط، وChip لمجموعة مرشحات ظاهرة.

وفر emptyMessage لتظهر رسالة توضيحية حين لا يجد البحث نتائج.

أمثلة

اختيار مفرد

قابل للبحث

اختيار متعدد

خيارات مجمعة

الخصائص

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

<Dropdown>

الخاصيةالنوعالافتراضيالوصف
size"md" | "lg"
variant"default" | "filled-lighter" | "filled-darker"
openboolean
defaultOpenboolean
onOpenChange(open: boolean) => void
labelreact.ReactNodeVisible label above the trigger.
helperTextreact.ReactNodeHint shown below the trigger when there's no error.
errorMessagereact.ReactNodeMessage shown below the trigger when error is true.
errorbooleanMarks the field invalid - sets aria-invalid and the error border.
requiredbooleanAdds the required asterisk and aria-required; with name, blocks native submit while empty.
namestringSubmits the selection under this name in native forms (FormData). Single submits the value, or "" when empty. multiple submits one entry per value under this exact name (read with getAll(name); pass name="cities[]" for PHP and Laravel), and nothing when empty.
formstringAssociates the hidden inputs with a <form> by id, like the native form attribute.
disabledbooleanDisables the trigger entirely.
readOnlybooleanShows the value but blocks opening (SDGA Read-only).
placeholderreact.ReactNodePlaceholder shown when nothing is selected.
searchablebooleanRender the in-panel filter input (combobox behavior). Off by default - the plain SDGA dropdown. A hidden focusable input is kept either way for cmdk's keyboard model.
searchPlaceholderstringPlaceholder for the filter input when searchable.
emptyMessagereact.ReactNodeShown when a filter matches nothing.
getLabel(value: string) => ReactNodeOverride the trigger label resolver (e.g. async-loaded options).
idstring
classNamestring
aria-labelstring
aria-labelledbystring
childrenإلزاميreact.ReactNode<DropdownItem> (+ optional DropdownGroup / DropdownSeparator).
multiplefalse
valuestring
defaultValuestring
onValueChange(value: string) => void

<DropdownItem>

الخاصيةالنوعالافتراضيالوصف
valueإلزاميstringStable value for filtering + selection.
keywordsstring[]Extra search terms cmdk matches against the filter input.
disabledbooleanWhether this item is currently disabled.
onSelect(value: string) => voidFires alongside the root's onValueChange.
childrenReactNode
asChildboolean
forceMountbooleanWhether this item is forcibly rendered regardless of filtering.

<DropdownGroup>

الخاصيةالنوعالافتراضيالوصف
headingreact.ReactNodeOptional heading to render for this group.
childrenReactNode
asChildboolean
valuestringIf no heading is provided, you must provide a value that is unique for this group.
forceMountbooleanWhether this group is forcibly rendered regardless of filtering.

<DropdownSeparator>

الخاصيةالنوعالافتراضيالوصف
asChildboolean
alwaysRenderbooleanWhether this separator should always be rendered. Useful if you disable automatic filtering.

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

يعرض المشغل aria-haspopup، وتستخدم تسمية الحقل، النص المساعد، ورسالة الخطأ الربط نفسه المستخدم في TextInput. داخل اللوحة، يتبع حقل البحث وقائمة الخيارات نمط combobox من cmdk، ويدعمان هذه المفاتيح: الأسهم للتنقل بين الخيارات، Enter لتبديل الخيار المظلل، وEscape للإغلاق.

تعلن التقنيات المساعدة القيم المختارة. وفي وضع الاختيار المتعدد، يبقى كل اختيار ظاهراً في المشغل.