Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Input Group examples · Dropdown

URL Builder with Dropdown Input Group for React

Two URL inputs, one with a protocol menu before it and one with a domain menu after it.

Framework
UI library

Build a URL from parts people pick and parts they type. The first field has an https:// Dropdown Menu at its start with https:// and http://; the second has a .com menu at its end with .com, .net, .org and .io.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

How does the protocol menu sit before the input?

Its InputGroupAddon keeps the default align, inline-start, which places it before the input. In the code it still comes after the input, as every addon does.

How does the domain menu sit after the input?

Its addon has align="inline-end".

How are the menu buttons built?

Each trigger is a ghost InputGroupButton with text-xs, the current value and a small chevron. DropdownMenuTrigger renders the InputGroupButton through render.

Where do the menus open?

Each opens under its button, aligned to the edge it sits on: start for the protocol, end for the domain.

Do the buttons show the chosen value?

Not here: they always read https:// and .com. Keep each choice in state, render it in its trigger and combine the parts into the URL.

How are the inputs labeled?

aria-label="Domain" and aria-label="Subdomain", since neither has a visible label.