Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

With Item Count in Trigger Combobox for Solid

A multi-select skill combobox that starts on JavaScript and TypeScript and reads 2 skills selected.

UI library: Ark UI

JavaScript and TypeScript start selected. The button says 2 skills selected, and the plural follows the count. The button stays one line however many skills are picked.

Use it where the button has to stay narrow and the number of picks is the useful summary. Showing each name as a chip fits a Combobox with chips. In Solid, Ark UI does not write the count. The button label does.

Preview

Preview width

Installation

MCP · Pro
Make your AI a shadcn expert
Your agent installs components, builds pages and restyles your app from one prompt, in Claude Code, Cursor or VS Code.
Part of Pro

Anatomy

Combobox anatomy: control, input, trigger, content, item, item indicator

Usage

<Combobox collection={_listCollection.collection()} multiple onInputValueChange={handleInputValueChange} onValueChange={handleValueChange} positioning={{
    getAnchorElement: () => triggerRef
  }} value={value()}>
      <ComboboxTrigger class={cn(buttonVariants({
      variant: "outline"
    }), "w-[200px] justify-between")} ref={triggerRef}>
        {value().length > 0 ? `${value().length} skill${value().length > 1 ? "s" : ""} selected` : "Select skills..."}
      </ComboboxTrigger>
      <ComboboxContent>
        <ComboboxInput class="w-full" placeholder="Search skills..." showTrigger={false} />
        <ComboboxEmpty>No skill found.</ComboboxEmpty>
        <ComboboxList>
          {_listCollection.collection().items.map(skill => <ComboboxItem item={skill}>
              {skill.label}
            </ComboboxItem>)}
        </ComboboxList>
      </ComboboxContent>
    </Combobox>

FAQ

How is the label built?

From the number of selected values: skill gets an s when there is more than one, so it reads 1 skill selected or 3 skills selected. With nothing picked it says Select skills....

What is selected at first?

JavaScript and TypeScript, the starting value of the selection the demo keeps.

Which skills are listed?

JavaScript, TypeScript, Python, Rust, Go and Java. The search box says Search skills..., and No skill found. shows when nothing matches.

How are picked skills marked?

ComboboxItem shows its check on every picked row, and a second pick clears it.

Can I show the names instead?

Yes, join the selected labels into the button text. Fall back to the count once the names no longer fit the 200px button.

Does the plural work in other languages?

No, the s rule only fits English. Use Intl.PluralRules or your translation library to pick the right form.

API Reference

Combobox

Sets collection={_listCollection.collection()}, multiple, onInputValueChange={handleInputValueChange}, onValueChange={handleValueChange}, positioning and getAnchorElement. The rest is on the Combobox page.