Skip to main content

Picker

Pickers are used to select one or more choices, such as tags, from a list. Use a picker to allow the user to quickly search for or manage a few tags.

The name attribute indicates how to reference this component in the query arguments: q.args.<name-attr>.

You can see the API for ui.picker or check the interactive example in Tour app.

Basic picker

picker-0

q.page['example'] = ui.form_card(box='1 1 2 2', items=[
ui.picker(name='picker', label='Picker', choices=[
ui.choice(name='spam', label='Spam'),
ui.choice(name='eggs', label='Eggs'),
ui.choice(name='ham', label='Ham'),
]),
])

With preselection

Use the values attribute to preselect certain tags.

picker-1

q.page['example'] = ui.form_card(box='1 1 2 2', items=[
ui.picker(name='picker', label='Picker', values=['eggs'], choices=[
ui.choice(name='spam', label='Spam'),
ui.choice(name='eggs', label='Eggs'),
ui.choice(name='ham', label='Ham'),
]),
])

With a limited selection

Wave also makes it possible to limit the number of choices a user might pick via the max_choices attribute.

picker-2

q.page['example'] = ui.form_card(box='1 1 2 2', items=[
ui.picker(name='picker', label='Picker', max_choices=2, choices=[
ui.choice(name='spam', label='Spam'),
ui.choice(name='eggs', label='Eggs'),
ui.choice(name='ham', label='Ham'),
]),
])

Disabled picker

Used for cases when the picker should not be changeable yet (e.g. waiting for filling some other form element first) or should serve as a read-only element.

picker-3

q.page['example'] = ui.form_card(box='1 1 2 2', items=[
ui.picker(name='picker', label='Picker', disabled=True, choices=[
ui.choice(name='spam', label='Spam'),
ui.choice(name='eggs', label='Eggs'),
ui.choice(name='ham', label='Ham'),
]),
])

Required picker

Renders a small asterisk next to the label. Used for cases when the input has to be provided, otherwise, the form is considered invalid.

picker-4

q.page['example'] = ui.form_card(box='1 1 2 2', items=[
ui.picker(name='picker', label='Picker', required=True, choices=[
ui.choice(name='spam', label='Spam'),
ui.choice(name='eggs', label='Eggs'),
ui.choice(name='ham', label='Ham'),
]),
])