SearchBarFallback

A lightweight static placeholder for the SearchBar, used as a Suspense fallback or initial server render.

Installation

pnpm add @wandercom/design-system-web

Usage

The SearchBarFallback renders static empty or preselected states that visually match the SearchBar on desktop and mobile. The mobile fallback is 48px tall in every context, matching the live mobile trigger. Wrap the real SearchBar in a Suspense boundary with the fallback to avoid layout shift during loading. By default the composed fallback establishes a 65rem (1040px) query container and switches layout from its own available width. Pass inheritContainer when its matching SearchBar follows an ancestor container.

Pass the live location label as locationLabel when it differs from locationPlaceholder, so both versions reserve the same text width.

11 lines
import { SearchBarFallback } from '@wandercom/design-system-web/ui/search-bar-fallback';
import { SearchBar } from '@wandercom/design-system-web/ui/search-bar';
import { Suspense } from 'react';

export function Example() {
  return (
    <Suspense fallback={<SearchBarFallback />}>
      <SearchBar />
    </Suspense>
  );
}

Examples

Default

The example renders live and fallback versions of both empty and preselected states at the same available width.

Loading example...

Props

SearchBarFallback

location?:

string
Selected location text shown in the desktop and mobile filled states.

dates?:

string
Selected dates text shown in the desktop and mobile filled states.

guests?:

string
Selected guests text shown in the desktop and mobile filled states.

locationPlaceholder?:

string
Location placeholder text for the desktop view. Defaults to "Where".

locationLabel?:

string
Expanded location label reserved for stable desktop width. Defaults to locationPlaceholder.

datesPlaceholder?:

string
Dates placeholder text for the desktop view. Defaults to "When".

guestsPlaceholder?:

string
Guests placeholder text for the desktop view. Defaults to "Who".

searchLabel?:

string
Search button label for the desktop view. Defaults to "Search".

mobilePlaceholder?:

string
Placeholder text for the mobile trigger. Defaults to "Start your search".

className?:

string
Additional CSS classes to apply to the root container.

inheritContainer?:

boolean
When true, responsive visibility follows the nearest ancestor query container rather than establishing a new container on the fallback root.

Accepts all standard div element props.

SearchBarFallbackDesktop and SearchBarFallbackMobile are lower-level exports. When rendered independently, place them beneath an @container ancestor if their responsive visibility should adapt to a parent width.

SearchBarFallbackDesktop

location?:

string
Selected location text.

dates?:

string
Selected dates text.

guests?:

string
Selected guests text.

locationPlaceholder?:

string
Location placeholder text. Defaults to "Where".

locationLabel?:

string
Expanded location label reserved for stable width. Defaults to locationPlaceholder.

datesPlaceholder?:

string
Dates placeholder text. Defaults to "When".

guestsPlaceholder?:

string
Guests placeholder text. Defaults to "Who".

searchLabel?:

string
Search button label. Defaults to "Search".

className?:

string
Additional CSS classes to apply to the desktop fallback.

Accepts all standard div element props.

SearchBarFallbackMobile

location?:

string
Selected location text. Enables the filled two-row mobile layout.

dates?:

string
Selected dates text shown beneath the location.

guests?:

string
Selected guests text shown beneath the location.

placeholder?:

string
Placeholder text shown in the mobile trigger. Defaults to "Start your search".

className?:

string
Additional CSS classes to apply to the mobile fallback.

Accepts all standard div element props.

Localized Copy

All visible text can be customized via props to support localization:

7 lines
<SearchBarFallback
  locationPlaceholder="Où ?"
  datesPlaceholder="Quand ?"
  guestsPlaceholder="Combien ?"
  searchLabel="Rechercher"
  mobilePlaceholder="Commencer la recherche"
/>

Behavior

This component renders static HTML with no client-side JavaScript, hooks, or state. It works as a React Server Component. At container widths of 65rem (1040px) and wider, it shows a pill-shaped bar with location, dates, and guests placeholders plus a search button. Below that width, it shows a centered pill with a search icon and placeholder text. All copy is customizable via props with sensible English defaults.

SearchBarFallback