Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Navigation

  • TabBar
  • Fab

Overlays

  • ActionSheet

Input

  • Picker

Gestures

  • SwipeAction
  • PullToRefresh

Layout

  • SafeArea

Picker

picker

Selects values through one or more scroll-snap wheel columns.

Usage

Single column selection

Single row roller, uncontrolled use defaultValue to set the initial item.

Apple
Banana
Orange
Grapes
Watermelon
tsx
<Picker columns={[fruits]} defaultValue={["orange"]} />

Multi-column linkage

columns passes multiple columns, that is, multiple scroll wheels (such as hours:minutes), and value is an array of selected values ​​for each column.

00
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
00
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
tsx
<Picker columns={[hours, minutes]} defaultValue={["9", "30"]} />

Number of visible lines

visibleCount controls the window height (an odd number is recommended), and itemHeight controls the row height.

Apple
Banana
Orange
Grapes
Watermelon
tsx
<Picker columns={[fruits]} visibleCount={3} itemHeight={36} />

When to Use

Use it on mobile to select one or more columns of discrete values, such as hour and minute or province, city, and district, with an iOS-style wheel interaction. Use ActionSheet for a simple list of actions; Picker is commonly placed inside an action sheet or bottom drawer.

Import

ts
import { Picker } from "@hulianui/ui"

Props

NameTypeDefaultDescription
columns *PickerColumn[]-Configuration of each column (see below)
valuestring[]-Array of selected values in each column (controlled)
defaultValuestring[]First item in each columnInitial value in uncontrolled mode
visibleCountnumber5Number of visible lines (odd number recommended)
itemHeightnumber40row height px
classNamestring--

PickerColumn: options: PickerOption[] · flex?: number (column flex ratio, default 1).
PickerOption: label: ReactNode · value: string.

Events

EventTypeDescription
onChange(value: string[], columnIndex: number) => voidCalled after a column settles, with the complete value array and changed column index

Usage Guidelines

  • value / defaultValue is a string array, each item corresponds to a column, and the value must match a value of the options in the column; the number of columns is consistent with the length of columns.
  • onChange fires only after scrolling settles and includes the changed column index. Highlighting and centering update immediately, but the callback is not emitted on every frame.

Related

TabBar · Fab · ActionSheet · SwipeAction · PullToRefresh · SafeArea

PreviousActionSheetMobileNextSwipeAction

On this page

  • Usage
  • Documentation
    • When to Use
    • Import
    • Props
    • Events
    • Usage Guidelines
    • Related