radix-ui / primitives

Radix Primitives is an open-source UI component library for building high-quality, accessible design systems and web apps. Maintained by @workos.
https://radix-ui.com/primitives
MIT License
15.88k stars 823 forks source link

[Select] Support multiple selections #1270

Open ghost opened 2 years ago

alissawix commented 6 months ago

just FYI, you can implement multiselect with the dropdown component and checkbox items it is a strange way to do it, but should be pretty easy to implement

zahidiqbalnbs commented 6 months ago

I've assembled a multi-select component using the native shadcn's components. It's fully in line with design and integrates seamlessly into shadcn's ecosystem. Please, try it out and share your thoughts. https://shadcn-multi-select-component.vercel.app/

Screenshot 2024-04-11 at 00 50 06

@sersavan can you move CommandInput search option within PopoverTrigger?

sersavan commented 6 months ago

I've assembled a multi-select component using the native shadcn's components. It's fully in line with design and integrates seamlessly into shadcn's ecosystem. Please, try it out and share your thoughts. https://shadcn-multi-select-component.vercel.app/

Screenshot 2024-04-11 at 00 50 06

@sersavan can you move CommandInput search option within PopoverTrigger?

@zahidiqbalnbs but why?

zahidiqbalnbs commented 6 months ago

I've assembled a multi-select component using the native shadcn's components. It's fully in line with design and integrates seamlessly into shadcn's ecosystem. Please, try it out and share your thoughts. https://shadcn-multi-select-component.vercel.app/

Screenshot 2024-04-11 at 00 50 06

@sersavan can you move CommandInput search option within PopoverTrigger?

@zahidiqbalnbs but why?

@sersavan thanks for your reply! You are a code guru and doing great stuff. The only reason for asking is if you look at react-select, antd multiselect, mui multiselect and others, all have search functionality within Input instead of providing them in Popover content. Thats why I am looking for if you can do that, would be really great!! Thanks again for all the wonderful work.

sersavan commented 6 months ago

I've assembled a multi-select component using the native shadcn's components. It's fully in line with design and integrates seamlessly into shadcn's ecosystem. Please, try it out and share your thoughts. https://shadcn-multi-select-component.vercel.app/

Screenshot 2024-04-11 at 00 50 06

@sersavan can you move CommandInput search option within PopoverTrigger?

@zahidiqbalnbs but why?

@sersavan thanks for your reply! You are a code guru and doing great stuff. The only reason for asking is if you look at react-select, antd multiselect, mui multiselect and others, all have search functionality within Input instead of providing them in Popover content. Thats why I am looking for if you can do that, would be really great!! Thanks again for all the wonderful work.

@zahidiqbalnbs I appreciate your feedback. If we add a search function to the popover, we need to decide which list to search through. In my component, the list is shown as a table. It would be more convenient to have the search bar in the same place as the table, rather than in the popover. Or propose your solution instead.

Rickiiii commented 4 months ago

+1 🚀

devdomsos commented 2 months ago

Would be awesome to have multiselect! +1

GetPsyched commented 2 months ago

Contrary to what @sersavan has made, and what some others want, I would much prefer this be as a multiple argument to the existing Select primitive (as the OP suggests). This is due to accessibility concerns and also DX.

<select> in HTML already supports choosing multiple selections, albeit in a weird way (it doesn't render as a normal dropdown anymore, but a scrollable block, which looks awful) I would prefer having a checkbox like select but still using <select> under-the-hood, and not creating a MultiSelect that many other libraries provide.

Another concern is that if you don't use the html <select> element, I cannot possibly use it in a form without a controlled input; this is horrible for server components that cannot have a stateful controlled element without making the entire form client-side.

Thanks.