Forms

Async multi-select.

Search remotely and keep the choices you have already made.

LIVE PREVIEWTry it. It works.

Install the source

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/async-multi-select.json

Registry setup · Examples · API and behavior · Open the playground

COMPLETE EXAMPLES

Use it in context.

Each example includes its imports, data and state. The preview runs that same source. Include the stylesheet once in your application.

Retain several stable choices

Selected labels remain available while the local asynchronous query changes.

Loads this example when you need it.

Keyboard

  • Type to search; Enter adds a highlighted choice.
  • Backspace and chip actions remove selected values.

States covered

  • No choices
  • Several choices
  • Filtered results

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-basic-async-multi-select.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import {useState} from 'react';
import {AsyncMultiSelect,UIProvider,type AsyncOptionsLoader,type AsyncOptionsResolver} from '@bld8/ui';
import '@bld8/ui/styles.css';
const people=[{value:'maya',label:'Maya Chen'},{value:'oliver',label:'Oliver Reed'},{value:'sam',label:'Sam Rivera'}];
const loadPeople:AsyncOptionsLoader=async({query,signal})=>{if(signal.aborted)throw new DOMException('Cancelled','AbortError');return {items:people.filter(person=>person.label.toLowerCase().includes(query.toLowerCase())),nextCursor:null};};
const resolvePeople:AsyncOptionsResolver=async({values,signal})=>{if(signal.aborted)throw new DOMException('Cancelled','AbortError');return people.filter(person=>values.includes(person.value));};
export default function MultiSourceExample(){const [peopleIds,setPeopleIds]=useState<string[]>(['maya']);return <UIProvider><AsyncMultiSelect label="Example review team source" value={peopleIds} onValueChange={setPeopleIds} loadOptions={loadPeople} resolveOptions={resolvePeople} hint="This asynchronous source uses local records."/><p>Selected IDs: {peopleIds.join(', ')||'none'}</p></UIProvider>;}

Controlled remote choices stay host owned

The host owns selected IDs through form reset and external updates. A read-only toggle prevents edits without disabling native submission.

Keyboard

  • Choose people with the keyboard, then reset the form without replacing the controlled values.
  • Lock the fields to read selections without opening a picker or removing a chip.
  • Host update replaces both controlled values explicitly.

States covered

  • Controlled reset ownership
  • Explicit host update
  • Read-only without mutation
  • Native stable IDs

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-async-controlled-form.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import '@bld8/ui/styles.css';
import {useCallback,useState} from 'react';
import {AsyncCombobox,AsyncMultiSelect,Button,Checkbox,UIProvider,type AsyncOptionsLoader} from '@bld8/ui';
const people=[{value:'maya',label:'Maya Chen'},{value:'sam',label:'Sam Rivera'},{value:'oliver',label:'Oliver Reed'}];
export default function AsyncControlledForm(){
  const [owner,setOwner]=useState<string|null>('maya'),[reviewers,setReviewers]=useState(['sam']),[locked,setLocked]=useState(false),[status,setStatus]=useState('Controlled values belong to this component.');
  const load=useCallback<AsyncOptionsLoader>(async({query,signal})=>{if(signal.aborted)throw new DOMException('Cancelled','AbortError');return {items:people.filter(person=>person.label.toLowerCase().includes(query.toLowerCase())),nextCursor:null};},[]);
  return <UIProvider><form style={{display:'grid',gap:20}} onReset={()=>setStatus('Native reset kept host values.')} onSubmit={event=>{event.preventDefault();setStatus(JSON.stringify([...new FormData(event.currentTarget).entries()]));}}>
    <AsyncCombobox label="Controlled assignee" name="owner" value={owner} onValueChange={setOwner} loadOptions={load} selectedOptions={people} readOnly={locked} debounceMs={0}/>
    <AsyncMultiSelect label="Controlled reviewers" name="reviewers" value={reviewers} onValueChange={setReviewers} loadOptions={load} selectedOptions={people} readOnly={locked} debounceMs={0}/>
    <Checkbox label="Lock controlled choices" checked={locked} onCheckedChange={setLocked}/>
    <div style={{display:'flex',gap:8,flexWrap:'wrap'}}><Button type="submit">Read controlled choices</Button><Button type="reset" variant="secondary">Reset controlled choices</Button><Button variant="ghost" onClick={()=>{setOwner('oliver');setReviewers(['maya','oliver']);}}>Host update</Button></div>
    <p role="status" aria-label="Controlled directory result">{status}</p>
  </form></UIProvider>;
}

Quick reference

React / TypeScript
<AsyncMultiSelect label="Reviewers" value={reviewers}
  onValueChange={setReviewers} loadOptions={loadPeople}
  resolveOptions={resolvePeople} />

In the workspace or ZIP starter, import components from @bld8/ui and include @bld8/ui/styles.css once. Registry installations use your local bld8/ source path. Wrap overlays in UIProvider.

API & behaviour

Uses the same paged and abortable source as AsyncCombobox. Up to 100 stable IDs remain selected across result pages and query changes; chips use retained or resolved labels. A missing label does not discard the value. Loading, page retry, selected-label retry and disabled options have separate feedback. Custom option rows must be presentational. Native forms submit IDs. See /examples/async-selection and /agent/guides/async-selection.md. Existing local MultiSelect keeps its original API and dependency graph.

Try remote search and recovery · Source contract

AsyncMultiSelect

AsyncMultiSelect public properties
PropTypeDefault
labelRequiredstring—
loadOptionsRequiredAsyncOptionsLoader<T>—
debounceMsnumber | undefined200
defaultValuestring[] | undefined[]
density"compact" | "comfortable" | undefined'comfortable'
disabledboolean | undefinedfalse
errorstring | undefined—
formstring | undefined

Native owning form, including a form outside the field.

—
hintstring | undefined—
inputRefRef<HTMLInputElement> | undefined—
labelVisibility"hidden" | "visible" | undefined'visible'
minQueryLengthnumber | undefined0
namestring | undefined—
onBlurFocusEventHandler<HTMLInputElement> | undefined—
onValueChange((values: string[]) => void) | undefined—
placeholderstring | undefined'Choose options…'
readOnlyboolean | undefined

Keeps canonical values submitted and focusable while preventing user edits.

false
renderOption((item: T) => ReactNode) | undefined—
requiredboolean | undefinedfalse
resolveOptionsAsyncOptionsResolver<T> | undefined—
selectedOptionsreadonly T[] | undefined—
sourceKeystring | undefined—
valuestring[] | undefined—

AsyncOption

AsyncOption public properties
PropTypeDefault
labelRequiredstring—
valueRequiredstring—
descriptionstring | undefined—
disabledboolean | undefined—

AsyncOptionsRequest

AsyncOptionsRequest public properties
PropTypeDefault
cursorRequiredstring | null—
queryRequiredstring—
signalRequiredAbortSignal—

AsyncOptionsPage

AsyncOptionsPage public properties
PropTypeDefault
itemsRequiredreadonly T[]—
nextCursorRequiredstring | null—

UseAsyncOptionsOptions

UseAsyncOptionsOptions public properties
PropTypeDefault
loadOptionsRequiredAsyncOptionsLoader<T>—
queryRequiredstring—
debounceMsnumber | undefined—
enabledboolean | undefined—
minQueryLengthnumber | undefined—
resolveOptionsAsyncOptionsResolver<T> | undefined—
selectedOptionsreadonly T[] | undefined

Seed selected labels; fetched records take precedence until the source changes.

—
selectedValuesreadonly string[] | undefined—
sourceKeystring | undefined

Change when a tenant, authorisation scope or parent branch changes.

—

AsyncOptionsState

AsyncOptionsState public properties
PropTypeDefault
canSearchRequiredboolean—
errorRequiredstring | null—
hasMoreRequiredboolean—
itemsRequiredreadonly T[]—
limitReachedRequiredboolean—
loadingRequiredboolean—
loadingMoreRequiredboolean—
loadMoreRequired() => void—
optionForValueRequired(value: string) => T | undefined—
resolutionErrorRequiredstring | null—
resolvingRequiredboolean—
retryRequired() => void—
retryResolutionRequired() => void—
statusRequiredAsyncOptionsStatus—

Tables come from the public TypeScript declarations. Related types and function parameters are shown alongside their component. A dash means no default is declared at the public function boundary.

Related controls

Notes to self

Test this component with real content, keyboard input and both themes. The example is a starting point; labels, error handling and behaviour still need to fit the application.