WUI logo

Picker

The Picker component is an interactive UI element that allows users to select a value from a predefined set of options. It can be used for various types of selections. This component enhances user experience by providing an intuitive and efficient way to make selections from a limited set of choices.

import * as React from 'react'
import { Picker } from '@welcome-ui/picker'
import { Shape } from '@welcome-ui/shape'
import { EditIcon, PencilIcon } from '@welcome-ui/icons'
const options = [
{
element: ({ selected }: { selected: boolean }) => (
<Shape backgroundColor={selected ? 'nude-200' : 'unset'} shape="circle" w={40}>
<EditIcon color="dark-900" />
</Shape>
),
value: 'edit',
},
{
element: ({ selected }: { selected: boolean }) => (
<Shape backgroundColor={selected ? 'nude-200' : 'unset'} shape="circle" w={40}>
<PencilIcon color="dark-900" />
</Shape>
),
value: 'pencil',
},
]
const Example = () => {
const [value, setValue] = React.useState('edit')
// TODO: fix typescript
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const handleChange = event => {
setValue(event.target.value)
}
return <Picker name="icon" onChange={handleChange} options={options} value={value} />
}
export default Example

Installation

1

Run the following command:

yarn add @welcome-ui/picker
2

Import component:

import { Picker } from '@welcome-ui/picker'