Dropdown
Genel görünümimport { Dropdown, DropdownOption } from '@nili/ui';Bu, kütüphanenin kendi genel görünüm sayfası — canlı olarak render ediliyor. Üstten dili veya temayı değiştirin, o da değişir.
Türler
Figma genel bakışındaki dört ön yuva deseni. Bir type prop’u yoktur — herhangi bir düğümü startAdornment ile geçin. Her örnek isteğe bağlı alt etiketi, bilgi simgesini ve ipucunu içerir.
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}
/>
)
}Boyutlar
Varsayılan md (40px). sm ve xs, Text Input ölçeğiyle eşleşir.
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} />
</>
)
}Görünümler
default tam alandır. compact, daha yoğun araç çubukları için kenarlığı kaldırır. inline yalnızca metindir.
import { Dropdown } from "@nili/ui"
export function Example() {
return (
<>
<Dropdown appearance="default" options={options} />
<Dropdown appearance="compact" options={options} />
<Dropdown appearance="inline" options={options} />
</>
)
}Aranabilir
Uzun listeler için searchable’ı açın. Liste klavyeyle gezilirken arama alanı odakta kalır.
import { Dropdown, Avatar } from "@nili/ui"
export function Example() {
return (
<Dropdown
label="Assignee"
placeholder="Search people…"
options={userOptions}
itemSize="lg"
searchable
searchPlaceholder="Search people…"
/>
)
}Devre dışı ve hata
Doğrulama iletisi göstermek için error verin; alan otomatik geçersiz işaretlenir. Devre dışı, gerçek disabled özniteliğidir.
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' >
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| 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
dahiliDropdownItem
dahiliVaryant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| size | sm | lg | sm | |
| selected | 'true' | 'false' | false | |
| active | 'true' | 'false' | false |
DropdownMenu
dahiliDropdownSearch
dahiliDropdownTrigger
dahiliVaryant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| size | md | sm | xs | md | |
| filled | 'true' | 'false' | false | |
| invalid | 'true' | 'false' | false | |
| appearance | default | compact | inline | default |