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

MonthYearPicker

MonthYearPicker 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 MonthYearPicker 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 { MonthYearPicker } from '@underverse-ui/underverse';

Ví dụ tương tác

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

MonthYearPicker

Component
Thuộc tínhMô tảKiểuMặc định
valueCurrent value as Date or {month, year}Date | { month: number; year: number }—
defaultValueDefault valueDate | { month: number; year: number }—
onChangeChange handler(value: { month: number; year: number; date: Date } | undefined) => void—
placeholderPlaceholder textstring"Select month/year"
disabledDisabled statebooleanfalse
sizeSize variantFormControlSize"md"
labelLabel textstring—
labelClassNameCustom class for labelstring—
requiredRequired fieldboolean—
clearableShow clear buttonbooleantrue
variantVisual variantMonthYearPickerVariant"default"
matchTriggerWidthMatch dropdown width to triggerbooleanfalse
monthNamesCustom month namesstring[]DEFAULT_MONTH_NAMES
shortMonthNamesCustom short month names for displaystring[]DEFAULT_SHORT_MONTH_NAMES
minYearMinimum year in rangenumber—
maxYearMaximum year in rangenumber—
minDateMinimum selectable dateDate—
maxDateMaximum selectable dateDate—
errorShow validation errorstring—
successSuccess stateboolean—
helperTextHelper textstring—
animateEnable smooth animationsbooleantrue
onOpenCallback when popover opens() => void—
onCloseCallback when popover closes() => void—
showThisMonthShow "This Month" buttonbooleantrue
columnLabelsColumn labels{ month?: string; year?: string }{ month: "Month", year: "Year" }
borderModeMã nguồn chưa cung cấp mô tả bổ sung.BorderMode—
getPortalContainerResolve the document element that should receive the picker portal.() => HTMLElement | null—

MonthYearPickerBase

Component
Thuộc tínhMô tảKiểuMặc định
valueCurrent value as Date or {month, year}Date | { month: number; year: number }—
defaultValueDefault valueDate | { month: number; year: number }—
onChangeChange handler(value: { month: number; year: number; date: Date } | undefined) => void—
placeholderPlaceholder textstring"Select month/year"
disabledDisabled statebooleanfalse
sizeSize variantFormControlSize"md"
labelLabel textstring—
labelClassNameCustom class for labelstring—
requiredRequired fieldboolean—
clearableShow clear buttonbooleantrue
variantVisual variantMonthYearPickerVariant"default"
matchTriggerWidthMatch dropdown width to triggerbooleanfalse
monthNamesCustom month namesstring[]DEFAULT_MONTH_NAMES
shortMonthNamesCustom short month names for displaystring[]DEFAULT_SHORT_MONTH_NAMES
minYearMinimum year in rangenumber—
maxYearMaximum year in rangenumber—
minDateMinimum selectable dateDate—
maxDateMaximum selectable dateDate—
errorShow validation errorstring—
successSuccess stateboolean—
helperTextHelper textstring—
animateEnable smooth animationsbooleantrue
onOpenCallback when popover opens() => void—
onCloseCallback when popover closes() => void—
showThisMonthShow "This Month" buttonbooleantrue
columnLabelsColumn labels{ month?: string; year?: string }{ month: "Month", year: "Year" }
borderModeMã nguồn chưa cung cấp mô tả bổ sung.BorderMode—
getPortalContainerResolve the document element that should receive the picker portal.() => HTMLElement | null—

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

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