You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-31Lines changed: 33 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,6 @@
1
-
# chakra-react-select
1
+
# chakra-react-select v3
2
+
3
+
> This version of `chakra-react-select` is for compatibility with React v17 and Chakra UI v1. It will be maintained until the majority of users have migrated to the newest version of Chakra. If you're using [Chakra UI v2](https://chakra-ui.com/guides/migration) check [the docs for chakra-react-select v4 here](https://github.com/csandman/chakra-react-select).
**NOTE:** Before leaving an issue on this project, remember that this is just a _wrapper_ for `react-select`, not a standalone package. A large percent of the questions people have end up being about how `react-select` itself works, so please read through their documentation to familiarize yourself with it! https://react-select.com/home
23
25
@@ -51,22 +53,22 @@ Check out the demos here:
51
53
52
54
## Usage
53
55
54
-
In order to use this package, you'll need to have `@chakra-ui/react` set up [like in the guide in their docs](https://chakra-ui.com/docs/getting-started#installation). If you don't have Chakra UI installed already, you can install it like this:
56
+
In order to use this package, you'll need to have `@chakra-ui/react` set up [like in the guide in their v1 docs](https://v1.chakra-ui.com/guides/first-steps). If you don't have Chakra UI installed already, you can install it like this:
55
57
56
58
```sh
57
-
npm i @chakra-ui/react @emotion/react@^11.8.1 @emotion/styled@^11 framer-motion@^6
59
+
npm i @chakra-ui/react@^1 @emotion/react@^11.8.1 @emotion/styled@^11 framer-motion@^6
**NOTE:** As of [`v3.3.3`](https://github.com/csandman/chakra-react-select/releases/tag/v3.3.3), your project will need to have a minimum of `@emotion/react@11.8.1` installed in order to avoid having multiple copies of `@emotion/react` installed. For more info, see [PR #115](https://github.com/csandman/chakra-react-select/pull/115).
63
65
64
-
After Chakra UI is setup, [install this package from NPM](https://www.npmjs.com/package/chakra-react-select):
66
+
After Chakra UI is setup, [install v3 of this package from NPM](https://www.npmjs.com/package/chakra-react-select) using either the `@3` version tag or the `@chakra1` npm tag:
65
67
66
68
```sh
67
-
npm i chakra-react-select
69
+
npm i chakra-react-select@chakra1
68
70
# ...or...
69
-
yarn add chakra-react-select
71
+
yarn add chakra-react-select@chakra1
70
72
```
71
73
72
74
Once installed, you can import the base select package, the async select, the creatable select or the async creatable select like so:
@@ -202,7 +204,7 @@ return (
202
204
203
205
One additional feature which isn’t specific to Chakra or react-select is sticky group headers. It adds a border to the bottom of the header and keeps it in view while its corresponding group of options is visible. This can be very nice for when you have long lists of grouped options so you can always tell which group of options you're looking at. To add it, pass the `hasStickyGroupHeaders` prop to the select component.
@@ -352,7 +354,7 @@ One change between the keys in the `chakraStyles` prop and the original `styles`
352
354
There are also two extra style keys for the icons contained within the indicators that are not offered in the original package. These are `downChevron` which is contained inside the `DropdownIndicator`, and the `crossIcon` which is contained inside the `ClearIndicator`. Both styles receive the same `state` values as their containing indicators. These style keys were added as a convenience, however you could also apply the same styles using the parent `chakraStyles` by doing something like this:
@@ -465,7 +467,7 @@ This package implements the same classNames on the sub components as the origina
465
467
>
466
468
> While we encourage you to use the new Styles API, you still have the option of styling via CSS classes. This ensures compatibility with [styled components](https://www.styled-components.com/), [CSS modules](https://github.com/css-modules/css-modules) and other libraries.
467
469
468
-
Here is an example of using classNames to style the components: https://codesandbox.io/s/chakra-react-select-classnameprefix-demo-4r2pe?file=/example.js
470
+
Here is an example of using classNames to style the components: https://codesandbox.io/s/chakra-react-select-classnameprefix-demo-v3-50pqn2?file=/example.js
469
471
470
472
## TypeScript Support
471
473
@@ -535,7 +537,7 @@ Like the original `react-select`, this package exports all of the custom compone
535
537
536
538
It's important to note however, that there are 3 components offered in the original `react-select` that are missing from `chakraComponents`. These are the `CrossIcon`, `DownChevron`, and `MenuPortal`. The `MenuPortal` could not be replaced at all [as mentioned earlier](#caveats), so if you'd like to customize it, use the original from the `components` import. The icons posed issues with prop compatibility when passing them into the core `Select` so the easiest way to replace them would be to use a custom `DropdownIndicator` or `ClearIndicator` and pass custom icons in as children:
@@ -722,14 +724,14 @@ See this issue for some discussion about using this package with `react-hook-for
722
724
By default, `react-hook-form` uses [uncontrolled components](https://reactjs.org/docs/uncontrolled-components.html) to reduced input renders however this only works for native HTML inputs. Because chakra-react-select is not a native HTML input, you'll need to use react-hook-form's [`Controller`](https://react-hook-form.com/api/usecontroller/controller) component or [`useController`](https://react-hook-form.com/api/usecontroller) hook in order to keep the value(s) tracked in `react-hook-form`'s state. Here are some examples using each:
723
725
724
726
-`Controller` multi select with built-in validation
0 commit comments