Đi tới nội dung tài liệu
Underverse UI Logo
ComponentPicker & Select

Combobox

Combobox thuộc nhóm Picker & Select. Xem demo trực tiếp, cách tích hợp và các lưu ý triển khai.

Bắt đầu nhanh

Import Combobox từ entry của gói Free. Các ví dụ bên dưới thể hiện những kiểu tương tác và cấu hình được hỗ trợ.

component.tsxtsx
import { Combobox } from '@underverse-ui/underverse';

Ví dụ tương tác

Dùng thử Combobox thật, xem mã ví dụ và tra cứu các prop đã được mô tả.

Đang tải ví dụ tương tác…
Tham chiếu

Tham chiếu API

Tra cứu các thuộc tính, kiểu dữ liệu được chấp nhận, giá trị mặc định và lưu ý về hành vi.

Dữ liệu được sinh từ API TypeScript công khai của thư viện. Kiểu dữ liệu, thuộc tính bắt buộc và giá trị mặc định luôn đồng bộ với mã nguồn.

Combobox

Component
Thuộc tínhMô tảKiểuMặc định
idId input (aria).string—
optionsBắt buộcDanh sách tuỳ chọn (string hoặc (label,value)).ComboboxOption[]Bắt buộc
valueGiá trị đã chọn.any—
onChangeBắt buộcHàm thay đổi (value).(value: any) => voidBắt buộc
placeholderPlaceholder của trigger.string—
classNameClass tuỳ chỉnh cho trigger.string—
disabledVô hiệu hoá.booleanfalse
sizeKích thước.FormControlSize"md"
variantBiến thể hiển thị."default" | "outline" | "ghost" | "filled""default"
allowClearHiển thị nút xoá lựa chọn.booleanfalse
searchPlaceholderPlaceholder ô tìm kiếm (khi nhiều lựa chọn).string—
emptyTextVăn bản khi không có kết quả.string—
usePortalRender dropdown bằng portal.booleantrue
getPortalContainerResolve the document element that should receive the dropdown portal.() => HTMLElement | null—
labelNhãn.string—
labelClassNameCustom class for labelstring—
requiredHiển thị dấu bắt buộc.boolean—
fontBoldIn đậm nhãn.booleanfalse
loadingMã nguồn chưa cung cấp mô tả bổ sung.booleanfalse
loadingTextMã nguồn chưa cung cấp mô tả bổ sung.string—
borderModeMã nguồn chưa cung cấp mô tả bổ sung.BorderMode—
showSelectedIconMã nguồn chưa cung cấp mô tả bổ sung.booleantrue
maxHeightMã nguồn chưa cung cấp mô tả bổ sung.number280
groupByMã nguồn chưa cung cấp mô tả bổ sung.(option: ComboboxOption) => string—
renderOptionMã nguồn chưa cung cấp mô tả bổ sung.(option: ComboboxOption, isSelected: boolean) => React.ReactNode—
renderValueMã nguồn chưa cung cấp mô tả bổ sung.(option: ComboboxOption) => React.ReactNode—
selectedOptionSelected option fallback for manual/server search when options does not contain the current value.ComboboxOption—
errorMã nguồn chưa cung cấp mô tả bổ sung.string—
helperTextMã nguồn chưa cung cấp mô tả bổ sung.string—
useOverlayScrollbarEnable OverlayScrollbars on dropdown options list. Default: true when not virtualizedbooleantrue
virtualizedVirtualize large flat option lists. Grouped lists fall back to normal rendering. Default: falsebooleanfalse
estimatedItemHeightEstimated option row height used by virtualized rendering. Default: 44number44
overscanNumber of extra rows rendered above and below the visible range. Default: 8number8
enableSearchControl whether the dropdown renders search UI and runs search logic. Defaults to automatic detection.boolean—
searchModeUse "manual" to let callers provide server-filtered options via onSearchChange. Default: "auto""auto" | "manual""auto"
onSearchChangeCalled whenever the search query changes. Required for manual/server search.(query: string) => void—
searchDebounceMsDebounce delay for onSearchChange. Default: 0number0
minSearchLengthMinimum query length before showing options in manual/search-prompt mode. Default: 0number0
maxInitialOptionsLimit the number of rendered options before the user types a query.number—
showSearchPromptWhenEmptyQueryShow a prompt instead of options while the query is shorter than minSearchLength. Default: falsebooleanfalse
matchTriggerBackgroundMatch dropdown background to the computed background of the combobox trigger. Default: falsebooleanfalse

Hướng dẫn sử dụng

Dùng Combobox khi lựa chọn có giới hạn nhanh và an toàn hơn nhập tự do. Cần cấu hình rõ locale, giới hạn, giá trị bị vô hiệu hóa và trạng thái xóa.

Trợ năng

Khi dùng Combobox, hãy giữ trạng thái focus dễ nhận biết, cung cấp tên truy cập khi cần và kiểm tra bàn phím cùng trình đọc màn hình trong ngữ cảnh thực tế.