Do we need a Multiselect component?
See original GitHub issueA Multiselect is a common input, and it seems like Chakra is missing it.
The API would use a compound component API. Example:
<Multiselect
selectedValues={[1, 2]}
onSelectedValuesChange={newValues => /* ... */}/>
<Option optionValue={1}>One</Option>
<Option optionValue={2}>Two</Option>
<Option optionValue={3}>Three</Option>
</Multiselect>
The API could be simpler and use strict props, but it would be less flexible. The compound component pattern would allow people to switch out the <Option />
component.
I would like to contribute to Chakra by writing this component, does this sound like a good addition?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:87
- Comments:47 (18 by maintainers)
Top Results From Across the Web
Building a multi-select component - web.dev
A foundational overview of how to build a responsive, adaptive, and accessible, multiselect component for sort and filter user experiences.
Read more >react-multi-select-component - npm
Prop Description Type
labelledBy value for aria‑labelledby string
options options for dropdown
value pre‑selected rows
Read more >KendoReact MultiSelect Overview - Telerik
The KendoReact MultiSelect is a form component that displays a list of options and allows for multiple selections from this list and supports...
Read more >React Multi Select Component - CoreUI
React multi selects use local CSS variables on .form-multi-select for enhanced real-time customization. Values for the CSS variables are set via Sass, so...
Read more >Creating a Multiselect Component as a Web Component
We want multiselect to get items right from the user markup. We can do this with a new HTML element <content> (you can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m not sure what the progress on this is but I wanted to share my wrapper for react-select’s multi component. I needed something like this to use with Chakra and wanted it to look the same so I spent a decent amount of time making it match visually. If you want to use it, here’s the source. Feel free to modify it as needed until an official Chakra version comes out.
I’m also curious if anyone has any recommendations to change this, I’m still very new to the inner workings of Chakra and I’m sure I didn’t do everything in the best way.
EDIT
I’ve noticed that this has gotten a positive reception so I figured I’d post an update. The wrapper I posted is now updated to more accurately work with the react-select controls, and also now has a size prop! it can accept
sm
,md
, andlg
and it reflects the sizes of the normal chakra text input. I also included a wrapper for the async version.EDIT 2
I made it into an NPM package! https://www.npmjs.com/package/chakra-react-select
EDIT 3
There have been some major improvements in version 2 and version 3 of this package, allowing for a fully customizable style system, and the native typescript support added in
react-select@5
. So if my component didn’t feel customizable enough at first, or you had issues implementing it in a TypeScript project, I highly recommend giving it a second chance.@mpiorowski @Mustycodes I just wanted to let you guys know, if you’re still looking for a component to do this, I have greatly improved my
chakra-react-select
component, specifically the TypeScript support. It should now work with TypeScript just as well as the originalreact-select
package does, as they added native TS support in v5 and I finally got my package updated to work on that version.