2.0.17 • Published 2 years ago

@paprika/select v2.0.17

Weekly downloads
2,069
License
MIT
Repository
github
Last release
2 years ago

@paprika/select

Description

The Select component is a styled select drop-down form input that can be used as a controlled or uncontrolled component.

Installation

yarn add @paprika/select

or with npm:

npm install @paprika/select

Props

Select

PropTyperequireddefaultDescription
a11yTextstringfalsenullProvides a non-visible label for this select element for assistive technologies.
childrennodefalsenullList of options as standard option elements.
defaultValuestringfalsenullSets the default selected value for an uncontrolled component.
hasErrorboolfalsefalseIf true displays a red border around select element to indicate error.
isDisabledboolfalsefalseIf true it makes the select element disabled.
isReadOnlyboolfalsefalseIf true it makes the select element read only.
onChangefuncfalse() => {}Callback to be executed when the selected value is changed. Receives the onChange event as an argument. Required when value prop is provided (component is controlled).
placeholderstringfalsenullDisplay value for a disabled first option with an empty string value.
size Select.types.size.SMALL, Select.types.size.MEDIUM, Select.types.size.LARGEfalseSelect.types.size.MEDIUMSpecifies the visual size of the select element.
valuestringfalseundefinedThe selected value for the select element.

Select.Container

All props and attributes are spread onto the root container <div> element.

Usage

The <Select> can be used as a controlled or an uncontrolled component.

To use it as a controlled component:

import Select from "@paprika/select";
...
const [value, setValue] = React.useState("Coke");
...
<Select
  value={value}
  onChange={event => setValue(event.target.value)}
>
  <option value="Coke">Coke</option>
  <option value="Pepsi">Pepsi</option>
</Select>

To use it as an uncontrolled component:

import Select from "@paprika/select";
...
const refSelect = React.useRef();
...
<Select
  defaultValue="Coke"
  ref={refSelect}
>
  <option value="Coke">Coke</option>
  <option value="Pepsi">Pepsi</option>
</Select>
...
refSelect.current.value // latest value

To access the value of an uncontrolled component, you can pass a handler function for the onChange prop that will have the event as an argument. You can use the event.target.value as needed.

Alternatively, you can include a ref on the component and access ref.current.value at any time.

Links

2.0.17-next.0

2 years ago

2.0.16-next.0

2 years ago

2.0.16

2 years ago

2.0.17

2 years ago

2.0.15-next.0

2 years ago

2.0.15

2 years ago

2.0.14

3 years ago

2.0.14-next.0

3 years ago

2.0.13-next.0

3 years ago

2.0.13-next.1

3 years ago

2.0.13

3 years ago

2.0.12-next.0

3 years ago

2.0.12-next.1

3 years ago

2.0.12-next.2

3 years ago

2.0.12

3 years ago

2.0.11-next.1

3 years ago

2.0.11-next.0

3 years ago

2.0.11

3 years ago

2.0.9

3 years ago

2.0.9-next.1

3 years ago

2.0.9-next.2

3 years ago

2.0.10-next.0

3 years ago

2.0.9-next.0

3 years ago

2.0.10

3 years ago

2.0.8-next.0

3 years ago

2.0.7

3 years ago

2.0.8

3 years ago

2.0.7-next.0

3 years ago

2.0.6

3 years ago

2.0.6-next.0

3 years ago

2.0.5

3 years ago

2.0.5-next.0

3 years ago

2.0.4

3 years ago

2.0.4-next.0

3 years ago

2.0.3

3 years ago

2.0.3-next.0

3 years ago

2.0.2

3 years ago

2.0.2-next.0

3 years ago

2.0.1

3 years ago

2.0.1-next.0

4 years ago

1.0.7

4 years ago

2.0.0-next.0

4 years ago

2.0.0

4 years ago

1.0.7-next.0

4 years ago

1.0.6

4 years ago

1.0.6-alpha.2

4 years ago

1.0.6-alpha.1

4 years ago

1.0.6-alpha.0

4 years ago

1.0.5

4 years ago

1.0.5-alpha.0

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.3-alpha.0

4 years ago

1.0.2

4 years ago

1.0.2-alpha.0

4 years ago

1.0.1

4 years ago

1.0.1-alpha.0

4 years ago

1.0.0

4 years ago

0.3.7

4 years ago

0.3.7-alpha.1

4 years ago

0.3.7-alpha.0

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.19

4 years ago

0.2.18

5 years ago

0.2.17

5 years ago

0.2.16

5 years ago

0.2.15

5 years ago

0.2.14

5 years ago

0.2.13

5 years ago

0.2.12

5 years ago

0.2.11

5 years ago

0.2.10

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.17

5 years ago

0.1.16

5 years ago

0.1.15

5 years ago

0.1.14

5 years ago

0.1.13

5 years ago

0.1.12

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

6 years ago