Multi Select
edgecom/multi-selectFreeComponent
The Edgecom Multi Select component.
Install it
npx shadcn@latest add https://design.edgecom.ai/r/multi-select.jsonSource
1'use client'23import * as React from 'react'45import { useEffect } from 'react'67import { Command as CommandPrimitive, useCommandState } from 'cmdk'8import { Command, CommandGroup, CommandItem, CommandList } from '@/components/ui/command'9import { cn } from '@/lib/utils'10import { XIcon } from "lucide-react"1112export interface Option {13 value: string14 label: string15 disable?: boolean1617 /** fixed option that can't be removed. */18 fixed?: boolean1920 /** Group the options by providing key. */21 [key: string]: string | boolean | undefined22}23interface GroupOption {24 [key: string]: Option[]25}2627interface MultipleSelectorProps {28 value?: Option[]29 defaultOptions?: Option[]3031 /** manually controlled options */32 options?: Option[]33 placeholder?: string3435 /** Loading component. */36 loadingIndicator?: React.ReactNode3738 /** Empty component. */39 emptyIndicator?: React.ReactNode4041 /** Debounce time for async search. Only work with `onSearch`. */42 delay?: number4344 /**45 * Only work with `onSearch` prop. Trigger search when `onFocus`.46 * For example, when user click on the input, it will trigger the search to get initial options.47 **/48 triggerSearchOnFocus?: boolean4950 /** async search */51 onSearch?: (value: string) => Promise<Option[]>5253 /**54 * sync search. This search will not showing loadingIndicator.55 * The rest props are the same as async search.56 * i.e.: creatable, groupBy, delay.57 **/58 onSearchSync?: (value: string) => Option[]59 onChange?: (options: Option[]) => void6061 /** Limit the maximum number of selected options. */62 maxSelected?: number6364 /** When the number of selected options exceeds the limit, the onMaxSelected will be called. */65 onMaxSelected?: (maxLimit: number) => void6667 /** Hide the placeholder when there are options selected. */68 hidePlaceholderWhenSelected?: boolean69 disabled?: boolean7071 /** Group the options base on provided key. */72 groupBy?: string73 className?: string74 badgeClassName?: string7576 /**77 * First item selected is a default behavior by cmdk. That is why the default is true.78 * This is a workaround solution by add a dummy item.79 *80 * @reference: https://github.com/pacocoursey/cmdk/issues/17181 */82 selectFirstItem?: boolean8384 /** Allow user to create option when there is no option matched. */85 creatable?: boolean8687 /** Props of `Command` */88 commandProps?: React.ComponentPropsWithoutRef<typeof Command>8990 /** Props of `CommandInput` */91// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from edgecom
All 66 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | edgecom | Components | Free | 2 deps | |
| Alertalert | edgecom | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | edgecom | Components | Free | 1 dep | |
| Avataravatar | edgecom | Components | Free | 1 dep | |
| Badgebadge | edgecom | Components | Free | 2 deps | |
| Bannerbanner | edgecom | Components | Free | 1 dep | |
| Breadcrumbbreadcrumb | edgecom | Components | Free | 2 deps | |
| Buttonbutton | edgecom | Components | Free | 2 deps |
