SwipeUI

Header search

A top bar with a centred title and a glass search button that stretches into a live field; on scroll it turns into a blur.

npx @swipeui/cli add header-search
Variant
Preset
Material
Scheme
Feel
Interactive web demo. Native materials, gestures and system presentation differ on device.

When to use it

  • Feeds and libraries where search is one tap away from anywhere, as in social and media apps.
  • A compact top bar with a menu or back button on one side and a create button on the other.
  • Apps that want a glass search capsule that opens in place instead of pushing a search screen.
  • When you show recent searches or live results under the bar while it's open.

When not to use it

  • Search as the main purpose of the screen. Keep a full Search field always visible.
  • Native stack headers with system search bars.
  • A large title that collapses on scroll. Use Collapsing header.
  • Expanding a search icon inline in a toolbar. Use Expanding search.

Installation

Installs with a Pro licence

Everything on this page is public except the source. Founder pre-sale opens around 5 January 2027.

Usage

app/library.tsx
import {
  HeaderSearch,
  HeaderSearchButton,
  headerSearchHeight,
} from '@/components/swipeui/header/header-search';
import { useHeaderScroll } from '@/components/swipeui/header/header-collapsing';

const insets = useSafeAreaInsets();
const header = useHeaderScroll();
const [query, setQuery] = useState('');

<View style={{ flex: 1 }}>
  <Animated.ScrollView
    onScroll={header.onScroll}
    scrollEventThrottle={16}
    contentContainerStyle={{ paddingTop: headerSearchHeight(insets.top) }}
  >
    {content}
  </Animated.ScrollView>
  <HeaderSearch
    title="Library"
    insetTop={insets.top}
    scrollY={header.scrollY}
    leading={<HeaderSearchButton icon={<BackIcon />} accessibilityLabel="Back" onPress={goBack} />}
    searchProps={{ placeholder: 'Search library', value: query, onValueChange: setQuery }}
    style={{ position: 'absolute', top: 0, left: 0, right: 0 }}
  />
</View>

API reference

PropTypeDefaultDescription
material?"auto" | GlassMaterial'auto'

Preferred material; unsupported choices fall back.

glassStyle?"clear" | "regular"'regular'

Native glass style.

blurTarget?React.RefObject<ReactNativeElement | null>—

Android requires a BlurTargetView ref for real blur.

blurIntensity?number60

Blur strength.

title?string—

The title, centred in the bar. It fades away once the content scrolls and while searching.

leading?ReactNode—

Before everything else, such as a back or menu button. Use HeaderSearchButton for a glass circle that matches.

searchProps?HeaderSearchFieldProps—

The field: its placeholder, value and callbacks.

active?boolean—

Controlled searching state: true while the search button is open as a field.

defaultActive?booleanfalse

Opens as a field.

onActiveChange?((active: boolean) => void)—

Called when search opens or closes. Show suggestions or results while it's true.

hideLeadingWhileActive?booleantrue

Moves the leading button out of the way while searching, so the field takes the row.

clearOnClose?booleantrue

Clears the query when the close button is pressed.

closeOnEmptyBlur?booleantrue

Closes search when the field loses focus with nothing typed.

scrollY?SharedValue<number>—

The content's vertical scroll offset, from useHeaderScroll(). Scrolling collapses the header.

collapseDistance?number44

How far the content scrolls before the header is fully collapsed.

backdrop?"blur" | "solid"'blur'

What the collapsed header shows behind its buttons: a blur of the content under it, or the solid background. Reduce Transparency, and Android without a blurTarget, use the solid background.

insetTop?number0

Extra space above the row, usually the top safe-area inset.

haptics?booleantrue

Plays a light tap when search opens and closes.

messages?HeaderSearchMessages—

Replaces the built-in wording.

motion?MotionOverridethe app feel

Local motion feel or spring override.

className?string—

Classes merged over the header.

style?StyleProp<ViewStyle>—

Style escape hatch for the header. Position it absolutely over the content so the blur has something to show.

testID?string—

The header gets testID, the search button ${testID}-open, the field ${testID}-field and the close button ${testID}-close.

Composition and behavior

  • A centred title, an optional leading button and a round glass search button on the trailing side. HeaderSearchButton draws a matching glass circle.
  • Tap search and it stretches across the bar into a live field: the title fades, the leading button shrinks away, the keyboard comes up and a round close button takes the trailing corner.
  • Close clears the query (clearOnClose) and brings everything back. hideLeadingWhileActive set to false keeps the leading button.
  • Leaving the field empty closes search (closeOnEmptyBlur); with a query it stays open, so results stay on screen.
  • With scrollY from useHeaderScroll, the title fades as the content scrolls and the bar turns into a blur of what is under it; back at the top the title returns. backdrop set to solid keeps the background, and collapseDistance sets how far the content scrolls first.
  • Float the header over the content and pad the content by headerSearchHeight(insets.top), so the blur has something to show.
  • active, defaultActive and onActiveChange let you show suggestions or results while it's open. The query and the search itself stay yours.
  • Glass is never faded: the pieces move by size and scale with the morph spring, and the blur fades by its intensity. Reduce Motion makes opening and closing instant.

Behavior and gestures

  • At rest the bar shows a centred title, an optional leading button and a round glass search button.
  • Tap search and it stretches across the bar into a field: the title fades, the leading button shrinks away, the keyboard comes up and a round close button takes the trailing corner.
  • Close clears the query (unless clearOnClose={false}), dismisses the keyboard and brings everything back.
  • Leaving the field empty closes search; with a query it stays open so results stay on screen.
  • As the content scrolls, the title fades and the bar turns into a blur of what is under it, keeping its buttons; back at the top the title returns.

Accessibility

  • At rest the capsule is a button named after the field, and it reads the current query.
  • While searching, the field is focused and the close button is labelled "Close search".
  • Side buttons leave the accessibility tree while they are hidden.
  • When the field is disabled or read-only, the capsule is disabled too.

Motion

  • Uses the morph and press motion roles, so it follows your app's feel. Pass motion to tune this one instance.
  • One morph spring stretches the search button into the field, shrinks the leading button and grows the close button, on the UI thread.
  • The collapse follows the scroll position; the blur fades by its intensity, never by opacity.
  • Reduce Motion makes opening and closing instant.

Performance

  • The morph runs from one shared value; opening and closing re-render once each, and scrolling never re-renders.

Notes for AI

  • Pass the query and handlers through searchProps; your app runs the search.
  • Use HeaderSearchButton for the leading button so it matches the search button.
  • Show suggestions or results while onActiveChange reports true.
  • Pass useHeaderScroll().scrollY so the bar collapses into a blur.

Compatibility

Runs onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items