Fragments
Multi Select
A multi-select component with badges and search.
FormanceCustom component built for Formance products.
Installation#
npx shadcn@latest add @formance/multi-selectInstall the following dependencies:
npm install lucide-reactCopy and paste the following code into your project.
Update the import paths to match your project setup.
Usage#
import { MultiSelect, MultiSelectContent, MultiSelectGroup, MultiSelectInput, MultiSelectItem, MultiSelectSeparator, MultiSelectTrigger, MultiSelectValue,} from '@/components/ui/multi-select'<MultiSelect defaultValues={['ledgers']}> <MultiSelectTrigger className="w-[280px]"> <MultiSelectValue placeholder="Select services..." /> </MultiSelectTrigger> <MultiSelectContent> <MultiSelectGroup> <MultiSelectItem value="ledgers">Ledgers</MultiSelectItem> <MultiSelectItem value="payments">Payments</MultiSelectItem> <MultiSelectItem value="wallets">Wallets</MultiSelectItem> </MultiSelectGroup> </MultiSelectContent></MultiSelect>Examples#
Controlled#
With Search#
No Search#
Disabled#
Creatable#
Overflow Wrap#
Overflow Cutoff#
Badge Label#
Groups#
Inline#
Inline Creatable#
Compound Components
Compose the pieces you need:
<MultiSelect />Root provider with controlled/uncontrolled values and popover or inline mode.<MultiSelectTrigger />Button that opens the dropdown and displays selected badges.<MultiSelectInput />Search input inside the trigger for filtering options.<MultiSelectValue />Renders selected values as badges with remove buttons.<MultiSelectContent />Dropdown content with command list.<MultiSelectItem />Selectable option with checkbox indicator.<MultiSelectGroup />Groups related items under a heading.<MultiSelectSeparator />Visual separator between groups.