Skip to content

Search Capsule

A recessed search field expands into a polished capsule as you type.

LIVE PREVIEWInteract with the component
Just React. No extra dependencies.

Copy the component and its CSS module into your project.

CSS Modules

Usage

Matches your current playground settings.

jsx
import SearchCapsule from "./SearchCapsule";
export default function Example() {
return (
<SearchCapsule
placeholder={"Find something good"}
label={"Search the collection"}
clearLabel={"Clear search"}
submitLabel={"Submit search"}
defaultValue={""}
color={"#b5bfcd"}
disabled={false}
name={"q"}
/>
);
}

Using Search Capsule

Connect onSearch to your search action and onValueChange to live results if needed. The component prevents native navigation, leaving result handling to your application.

This component renders its own search form, so place it outside other forms. The clear button restores focus to the input and the capsule remains within its container.

Props

NameTypeRequiredDefaultDescription
valuestringNoundefinedControlled search query.
defaultValuestringNo""Initial uncontrolled query.
onValueChangefunctionNoundefinedReceives the query as it changes.
onSearchfunctionNoundefinedReceives the current query on submit.
placeholderstringNo"Search"Input placeholder.
labelstringNo"Search"Accessible form and input label.
clearLabelstringNo"Clear search"Clear button label.
submitLabelstringNo"Submit search"Submit button label.
colorstringNo"#b5bfcd"Focus border and icon colour.
disabledbooleanNofalseDisable input and buttons.
namestringNo"q"Native input field name.
classNamestringNo""Additional classes on the root element.
styleCSSPropertiesNoundefinedInline styles for sizing, typography and appearance.

Related components

A recessed password field pairs a reveal control with an optional strength indicator.

Editable tags collect inside a softly framed input with individual remove controls.

Faceted stars lift into selection with a small marker beneath the chosen rating.

A bank of tactile keys holds independent selections with illuminated indicators.