Skip to content

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

Free

Button Group with Select for Solid

A country select in front of +1 (555) 123-4567, and an https select in front of example.com.

UI library: Ark UI

Two joined fields. The text cannot be edited. The country select starts on US, with UK and EU as well, in front of +1 (555) 123-4567. The protocol select starts on https://, can be http://, and keeps its own selection, in front of example.com. The flags are emoji.

Use this when a value has a fixed second half. For a number someone can type, put an Input in that spot. In Solid, Ark UI does not treat the phone text as a field.

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

Button Group anatomy: root, group, button, separator

Usage

<div class="flex flex-col gap-4">
      <ButtonGroup aria-label="Phone number">
        <Select collection={countries} onValueChange={handleCountryChange} value={country()}>
          <SelectTrigger aria-label="Country" class="bg-background">
            <SelectValue />
          </SelectTrigger>
          <SelectContent>
            <SelectGroup>
              {countries.items.map(item => <SelectItem item={item}>
                  {item.label}
                </SelectItem>)}
            </SelectGroup>
          </SelectContent>
        </Select>
        <ButtonGroupText>+1 (555) 123-4567</ButtonGroupText>
      </ButtonGroup>
      <ButtonGroup aria-label="Website">
        <Select collection={protocols} defaultValue={["https"]}>
          <SelectTrigger aria-label="Protocol" class="bg-background">
            <SelectValue />
          </SelectTrigger>
          <SelectContent>
            <SelectGroup>
              {protocols.items.map(item => <SelectItem item={item}>
                  {item.label}
                </SelectItem>)}
            </SelectGroup>
          </SelectContent>
        </Select>
        <ButtonGroupText>example.com</ButtonGroupText>
      </ButtonGroup>
    </div>

FAQ

How is the country select controlled?

The demo keeps the country, starting at us, and updates it when the select changes. Ark's select takes the value as a list, so it starts as ["us"].

Why does the protocol select have no state?

It starts on https with a default value and keeps its own selection. Read it on submit, or control it like the country select.

Is the phone number editable?

No. ButtonGroupText is fixed text that shares the group's border. Put an Input in its place for a real phone or domain field.

How are the selects named?

With aria-label, Country and Protocol, since they have no visible label. The label goes on SelectTrigger.

Will the flags show everywhere?

They're emoji. Some systems, such as Windows, show letter pairs instead of flags. Use flag images if that matters.

How wide is the select?

The trigger sizes to its value inside the group. Set a width class on SelectTrigger to fix it.

API Reference

Button Group

Sets aria-label="Phone number" and aria-label="Website". The rest is on the Button Group page.

Select

Sets collection={countries}, onValueChange={handleCountryChange}, value={country()}, aria-label="Country", item={item} and collection={protocols}. The rest is on the Select page.