question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Do we need a Multiselect component?

See original GitHub issue

A 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:closed
  • Created 3 years ago
  • Reactions:87
  • Comments:47 (18 by maintainers)

github_iconTop GitHub Comments

93reactions
csandmancommented, Jan 10, 2022

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, and lg 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.

20reactions
csandmancommented, Jan 10, 2022

@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 original react-select package does, as they added native TS support in v5 and I finally got my package updated to work on that version.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found