Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Input Group examples · Buttons

Search Button Input Group for React

A search input with a labeled Search button at its end.

Framework
UI library

A search field with an explicit button, for searches that run on submit rather than as people type. The secondary InputGroupButton with a magnifying glass sits in an inline-end addon after the input, with a little end padding.

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 is the Search button built?

An InputGroupButton with size="sm" and variant="secondary", its text followed by a magnifying glass marked data-icon="inline-end".

Why does the addon have pe-2?

It adds a little padding after the button so it doesn't touch the group's rounded end.

How do I run the search?

Wrap the group in a form and give the button type="submit", so Enter in the input and a click on the button both submit. InputGroupButton defaults to type="button".

Why type=search on the input?

It tells the browser and assistive tech this is a search field, and mobile keyboards show a search key. The input also has aria-label="Search" because there's no visible label.

Can I show only the icon?

Yes: drop the text, use size="icon-xs" and give the button aria-label="Search".

Does it work right to left?

Yes. The addon is inline-end and the padding is pe-2, so both follow the text direction.