JGuang

PickerView

PickerView · Ant Design Mobile

Preview
npm install antd-mobile@5.43.0

PickerView

The PickerView series includes three components: PickerView, CascadePickerView and DatePickerView.

Install

npm install antd-mobile@5.43.0

antd-mobile is for mobile web, not React Native or Mini Programs. React 19 projects must register createRoot with unstableSetRender at the entry, or imperative APIs such as Toast and Dialog cannot render. Switch dark mode with <html data-prefers-color-scheme="dark">.

Examples come from the official Ant Design Mobile repository (MIT) at the commit published as npm 5.43.0. Presentation helpers such as DemoBlock are JGuang rewrites, not antd-mobile APIs.

The PickerView series includes three components: PickerView, CascadePickerView and DatePickerView.

PickerView

PickerView is the content area of Picker.

Demos

Props

NameDescriptionTypeDefault
columnsOptions to configure each columnPickerColumn[] | ((value: PickerValue[]) => PickerColumn[])-
defaultValueDefault selected optionsPickerValue[][]
mouseWheelWhether to allow interact with mouse wheelbooleanfalse
onChangeTriggered when the options are changed(value: PickerValue[], extend: PickerValueExtend) => void-
renderLabelThe function to custom rendering the label shown on a column(item: PickerColumnItem) => ReactNode(item) => item.label
valueSelected optionsPickerValue[]-
loadingShould the Picker displays as loading statebooleanfalse
loadingContentThe loading content displayed in loading stateReactNodeprovide a default SpinLoading content

For the type definition of PickerColumnItem PickerColumn PickerValue PickerValueExtend, please refer to the document of Picker.

CSS Variables

NameDescriptionDefault
--heightHeight of PickerView.240px
--item-font-sizeFont size of option items.16px
--item-heightHeight of option item. Only supports px rem and vw units.34px

CascadePickerView

CascadePickerView is the content area of CascadePicker.

Demos

Props

NameDescriptionTypeDefault
optionsData of the tree optionsCascadePickerOption[]-

For the type definition of CascadePickerOption, please refer to the document of CascadePicker.

Other props are the same as PickerView, but columns are not supported.

CSS Variables

Same as PickerView.

DatePickerView

DatePickerView is the content area of DatePicker.

Demos

Props

type PickerDate = Date & {
  tillNow?: boolean
}
NameDescriptionTypeDefaultVersion
defaultValueDefault selected optionsPickerDate-
filterFilter available timeDatePickerFilter-
maxMax valuePickerDateten years later
minMinimum valuePickerDateten years ago
mouseWheelWhether to allow interact with mouse wheelbooleanfalse
onChangeTriggered when the options are changed(value: PickerDate) => void-
precisionPrecision'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'week' | 'week-day' | 'quarter''day'
renderLabelThe function to custom rendering the label shown on a column. type means any value in precision, data means the default number(type: string, data: number) => ReactNode-
valueSelected optionsPickerDate-
loadingShould the Picker displays as loading statebooleanfalse
loadingContentThe loading content displayed in loading stateReactNodeprovide a default SpinLoading content
tillNowShow till now in listboolean-5.32.0

For the type definition and usage of DatePickerFilter, please refer to the document of DatePicker.

CSS Variables

Same as PickerView.