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

CategoryTreeSelect

Đã cập nhật

CategoryTreeSelect 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 CategoryTreeSelect từ entry công khai. 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 { CategoryTreeSelect } from '@underverse-ui/underverse';

Ví dụ tương tác

Dùng thử CategoryTreeSelect 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.

CategoryTreeSelect

Component
Thuộc tínhMô tảKiểuMặc định
singleSelectChỉ cho phép chọn 1 node.false
valueSelected category ids. Selected category id or `null` when nothing is selected.number[]
onChangeCalled with the full selected id list. Called with the selected id or `null`.(selectedIds: number[]) => void
idMã nguồn chưa cung cấp mô tả bổ sung.string
labelOptional field label rendered above the control.string
labelClassNameExtra classes for the label element.string
categoriesBắt buộcFlat category list. Parent/child relationships are resolved via `parent_id`.Category[]Bắt buộc
placeholderPlaceholder text when no category is selected.string
disabledDisables interaction and fades the control.boolean
requiredParticipate in form-required validation.boolean
sizeVisual size of the trigger.FormControlSize
variantVisual style of the trigger."default" | "outline" | "ghost" | "filled"
allowClearShow a clear button when a selection exists.boolean
errorExternal error message. Takes precedence over helper text.string
helperTextHelper text shown below the field when there is no error.string
viewOnlyWhen true, renders as a read-only tree view without selection behavior.boolean
defaultExpandedExpand every parent node by default.boolean
defaultExpandedIdsExplicit branch ids that should start expanded in uncontrolled mode.number[]
expandToIdExpand the ancestor path so a specific node is visible by default.number | null
expandedIdsControlled expanded branch ids.number[]
onExpandedChangeCalled whenever expand/collapse changes the expanded branch ids.(expandedIds: number[]) => void
enableSearchEnable search input for filtering categories. Default: auto-enabled when `categories.length > 10` (similar to MultiCombobox).boolean
labelsReplace built-in labels for localization or custom wording.CategoryTreeSelectLabels
inlineRender the tree directly instead of inside a dropdown trigger.boolean
onNodeClickCalled when a node row is clicked. Useful for navigation flows.(node: Category) => void
classNameCustom class for the outer tree container.string
useOverlayScrollbarEnable OverlayScrollbars for the dropdown tree viewport. Default: `false`.boolean
leafOnlySelectWhen true, only leaf nodes can be selected; parent nodes only expand/collapse.boolean
virtualizedVirtualize the dropdown tree by rendering only visible rows. Inline/view-only trees keep recursive rendering.boolean
estimatedItemHeightEstimated tree row height used by virtualized rendering. Default: `36`.number
overscanNumber of extra rows rendered above and below the visible range. Default: `8`.number
maxInitialOptionsLimit the number of rendered rows before the user types a query.number
searchModeUse `"manual"` to let callers provide server-filtered categories via `onSearchChange`. Default: `"auto"`."auto" | "manual"
onSearchChangeCalled whenever the search query changes. Useful for manual/server search.(query: string) => void
searchDebounceMsDebounce delay for `onSearchChange`. Default: `0`.number
minSearchLengthMinimum query length before showing options in manual/search-prompt mode. Default: `0`.number
showSearchPromptWhenEmptyQueryShow a prompt instead of options while the query is shorter than `minSearchLength`. Default: `false`.boolean
renderItemActionsRender custom actions at the trailing edge of each tree row.(category: Category) => React.ReactNode
baseIndentBase left padding in rem applied to every node regardless of depth. Default: `0`.number
indentSizeAdditional left padding in rem added per depth level. Default: `0.75`.number
showTreeLinesShow dashed vertical guide lines between parent and child levels. Default: `true`.boolean
borderModeMã nguồn chưa cung cấp mô tả bổ sung.BorderMode

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

Dùng CategoryTreeSelect 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 CategoryTreeSelect, 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ế.