Skip to content

EntityTypeMultiPicker

Picks any number of entity types of a site, from a searchable list of everything the site has enabled.

Single and multi: EntityTypePicker takes one type.

Terminal window
pnpm dlx shadcn@latest add https://sg-widgets.vercel.app/r/react/entity-type-multi-picker.json
Terminal window
pnpm dlx shadcn-svelte@latest add https://sg-widgets.vercel.app/r/svelte/entity-type-multi-picker.json
EntityTypeMultiPicker: allow and deny lists, summary modes, codes, sizes and states

React

Loading the React demo…

Svelte

Loading the Svelte demo…

proptypedefaultmeaning
summary'chips' | 'ellipsis' | 'count''ellipsis'What the control shows for the selection.
maxnumber0Chips drawn before the rest becomes +n. 0 lets the row fit what it can.
contextfrom EntityTypePickerSgContextrequiredThe widget context. The site's enabled types are read through it, once per page.
valuestring[][]The chosen type codes, in the order they were ticked. Two-way in Svelte.
allowfrom EntityTypePickerstring[]—Codes on offer. Empty or absent means every enabled type.
denyfrom EntityTypePickerstring[]—Codes withheld, applied after allow.
showCodefrom EntityTypePickerbooleantrueShows the code under the display name where the two differ.
className / classfrom EntityTypePickerstring—Merged after the widget's own classes.
sizefrom PickerControl'sm' | 'md' | 'lg''md'Control height: 7, 8 and 9.
disabledfrom PickerControlbooleanfalse
readonlyfrom EntityTypePickerbooleanfalseKeeps full contrast and removes the chevron and the clear control.
invalidfrom EntityTypePickerbooleanfalseApplies the invalid ring and aria-invalid.
clearablefrom EntityTypePickerbooleantrueShow the clear control once something is chosen.
placeholderstring'Select entity types'Shown while nothing is chosen.
searchPlaceholderfrom EntityTypePickerstring'Search types…'Shown in the search box.
openfrom PickerControlbooleanrequiredReact: whether the popup is showing.
openfrom PickerControlbooleanfalseSvelte: whether the popup is showing, two-way.
emptyLabelfrom EntityTypePickerstring'No match'Shown when the search matches nothing.
loadingLabelfrom EntityTypePickerstring'Loading…'Names the skeletons a read stands behind, for a screen reader.
errorLabelfrom EntityTypePickerstring—Shown in place of what the failed read said.

Every row carries a checkbox and the list stays open across selections. Each selection is a chip in the control, with its own remove control.

chips makes the control a token field: every chip, wrapped, with the caret beside them, and +n after the last chip max allows. ellipsis makes it a one-line trigger: as many whole chips as the row fits, never a cut one, then +n inline after the last, the whole list in the tooltip, and the search box at the top of the popup. count makes it the same trigger reading 3 selected. A press on +n opens the list, where the hidden rows are.

allow is applied first and deny second, both to the derived list rather than to the read, so a caller narrowing the set sees the list change with no second call.

eventpayloadwhen
onValueChangestring[]A type is ticked or unticked, or the clear control is pressed.
onOpenChangefrom EntityTypePickerbooleanThe popup opened or closed. Svelte also binds it with bind:open.

None.

keydoes
any textNarrows the rows, from the caret under chips and from the popup's search box otherwise.
Enter, Spacefrom EntityTypePickerOn the chevron, opens the list.
Down, Upfrom EntityTypePickerMove the cursor through the rows and keep it in view. The last row holds it rather than wrapping.
ArrowDown / ArrowUpfrom PickerControlMoves the highlight, and the list scrolls it into view.
EnterTicks or unticks the highlighted type. The list stays open.
Escapefrom EntityTypePickerClose, keeping the value and clearing the query. On a closed picker it does nothing.
BackspaceIn an empty search box, highlights the last chip. A second one removes it. Any other key releases it.
ArrowLeft / ArrowRightfrom PickerControlOn a chip, walks the row. ArrowRight past the last chip returns to the input.
Deletefrom PickerControlOn a chip, removes it and leaves the caret on its neighbour.
TabMoves through the chips' remove controls, then +n, the clear control and the chevron.

GET /schema returns every enabled type in about 12KB, custom slots included, and presence in that listing is the enablement test: a slot absent from it 404s everywhere else. The display name is the type’s name, and the key is what a URL and a dotted path take (002_schema).

The row, chip and checkbox anatomy follows shadcn’s Base UI Combobox, read through shadcn 4.21.0. The primitive underneath is Base UI Combobox 1.8.0 in React and Bits UI Combobox 2.19.1 in Svelte. shadcn-svelte ships no combobox item, so each widget composes the headless primitive of its framework and both draw the same rows, the same classes and the same states.