Dropdown
عرض شاملimport { Dropdown, DropdownOption } from '@nili/ui';هذه صفحة العرض الشامل الخاصة بالمكتبة، معروضة حيّة. غيّر اللغة أو السمة من الأعلى وسَتتبعك.
الأنواع
أنماط الفتحة المتقدّمة الأربعة من نظرة فيجما العامة. ولا توجد خاصية type — مرِّر أي عنصر عبر startAdornment. ويتضمّن كل مثال التسمية الفرعية الاختيارية ورمز المعلومات والتلميح.
This is a hint text to help user.
This is a hint text to help user.
This is a hint text to help user.
This is a hint text to help user.
import {
Dropdown,
Icon,
Avatar,
CountryFlag,
PlaceholderLogo,
} from "@nili/ui"
import { RiFlashlightLine } from "@remixicon/react"
// Icon
const iconOptions = [
{
value: "design",
label: "Design",
startAdornment: <Icon icon={RiFlashlightLine} />,
},
]
// Country
const countryOptions = [
{
value: "ir",
label: "Iran",
startAdornment: <CountryFlag code="ir" size="sm" />,
},
]
// User
const userOptions = [
{
value: "sophia",
label: "Sophia Williams",
description: "Product design",
startAdornment: <Avatar size="3xs" name="Sophia Williams" />,
},
]
// Company
const companyOptions = [
{
value: "apex",
label: "Apex Financial",
description: "Finance & Banking",
startAdornment: (
<PlaceholderLogo company="apex-financial" size="xs" label="" />
),
},
]
export function Example() {
return (
<Dropdown
label="Label"
sublabel="(Optional)"
information
hint="This is a hint text to help user."
placeholder="Select…"
options={iconOptions}
/>
)
}الأحجام
الحجم md (٤٠ بكسل) هو الافتراضي. ويطابق sm وxs مقياس Text Input.
import { Dropdown } from "@nili/ui"
export function Example() {
return (
<>
<Dropdown size="md" label="Medium" options={options} />
<Dropdown size="sm" label="Small" options={options} />
<Dropdown size="xs" label="X-Small" options={options} />
</>
)
}المظاهر
النمط default هو الحقل الكامل. ويُسقط compact الإطار لأشرطة أدوات أكثف. وinline نصّي فقط.
import { Dropdown } from "@nili/ui"
export function Example() {
return (
<>
<Dropdown appearance="default" options={options} />
<Dropdown appearance="compact" options={options} />
<Dropdown appearance="inline" options={options} />
</>
)
}قابل للبحث
فعّل searchable للقوائم الطويلة. ويبقى حقل البحث مركّزًا أثناء التنقّل في القائمة بلوحة المفاتيح.
import { Dropdown, Avatar } from "@nili/ui"
export function Example() {
return (
<Dropdown
label="Assignee"
placeholder="Search people…"
options={userOptions}
itemSize="lg"
searchable
searchPlaceholder="Search people…"
/>
)
}معطّل وخطأ
مرِّر error لعرض رسالة تحقّق؛ ويُعلَّم الحقل غير صالح تلقائيًا. وdisabled هي السمة disabled نفسها.
Please select an option
import { Dropdown } from "@nili/ui"
export function Example() {
return (
<>
<Dropdown disabled label="Disabled" options={options} />
<Dropdown
label="Required field"
options={options}
error="Please select an option"
/>
</>
)
}Dropdown
extends Omit< ComponentPropsWithoutRef<'div'>, 'onChange' | 'defaultValue' | 'children' >
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| options* | DropdownOption[] | — | |
| value | string | null | — | |
| defaultValue | string | null | — | |
| onChange | (value: string) => void | — | |
| placeholder | ReactNode | Select… | |
| size | md | sm | xs | md | |
| itemSize | lg | sm | sm | |
| appearance | default | compact | inline | default | |
| disabled | boolean | false | |
| invalid | boolean | false | |
| searchable | boolean | false | Figma misc. item "Search". |
| searchPlaceholder | string | Search… | |
| emptyMessage | ReactNode | No results | |
| footer | ReactNode | — | Figma misc. items "Button" / "Button Group", pinned under the list. |
| label | ReactNode | — | Figma `🔖 Label` — the visible label above the field, drawn with the same `Label` component the Text Input page uses. |
| sublabel | ReactNode | — | Figma Label's `💬 Sublabel` — the muted "(Optional)". |
| information | boolean | ReactNode | false | Figma Label's `ℹ️ Information` glyph. `true` uses the default icon. |
| informationLabel | string | — | Accessible name for that glyph. |
| labelAction | ReactNode | — | Figma Label's `🌟 Button` — trailing slot on the label row. |
| hint | ReactNode | — | Figma `💡 Hint Text` — the line under the field. |
| error | ReactNode | — | Validation message. Its presence is what marks the field invalid. |
| badge | ReactNode | — | Figma `🎖️ Badge` — inside the trigger, after the value. |
| ariaLabel | string | — | Accessible name when no visible `label` is rendered. |
| required | boolean | — | |
| rootClassName | string | — | Applied to the outer wrapper rather than to the field. |
| triggerClassName | string | — | |
| menuClassName | string | — |
DropdownCaption
داخليDropdownItem
داخليمحاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| size | sm | lg | sm | |
| selected | 'true' | 'false' | false | |
| active | 'true' | 'false' | false |
DropdownMenu
داخليDropdownSearch
داخليDropdownTrigger
داخليمحاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| size | md | sm | xs | md | |
| filled | 'true' | 'false' | false | |
| invalid | 'true' | 'false' | false | |
| appearance | default | compact | inline | default |