Skip to main content

Migrate EmptySearchResult from Polaris React

Replace Polaris React EmptySearchResult with s-empty-state after a completed search or filter query returns no matches. Keep the query controls visible and use the primary action to clear or broaden the query.

s-empty-state is available in Polaris 1.1 and later. The stable channel, polaris-1.js, includes it; install @shopify/polaris-types@^1.1.0 alongside it. If you pin polaris-1.1.js instead, use @shopify/polaris-types@~1.1.0 so the types stay on 1.1 like the script tag.


Anchor to Choose the destinationChoose the destination

Polaris ReactPolaris web componentsMigration type
EmptySearchResults-empty-stateDirect

Anchor to Map the empty search resultMap the empty search result

Polaris ReactPolaris web componentsMigration notes
titleheadingInclude the active query when it helps merchants understand why no results appear.
descriptions-text in the subheading slotSuggest a concrete next step, such as changing filters or clearing the search.
withIllustrationOptional s-icon or s-image in the graphic slotOmit the graphic in dense tables. If used, keep it decorative unless it communicates information not present in the text.
Search and filter stateKeep controls outside s-empty-state; add a clear action in primary-actionClear the same state used to build the backend request, then request the unfiltered results.

Anchor to Migrate the call siteMigrate the call site

  1. Keep search and filter controls mounted while the completed request has no results.

  2. Render s-empty-state only when the request has completed and the filtered result set is empty.

  3. Connect the clear action to all applied query state and trigger the same data-loading path used by the controls.

  4. After verification, remove the EmptySearchResult import and any Polaris-only state, wrappers, or helpers that no longer have a caller.


Anchor to Preserve these behaviorsPreserve these behaviors

  • The current query and applied filters remain visible.
  • Clearing the query updates both the controls and backend results.
  • Loading, empty, populated, and error states remain mutually exclusive.

Anchor to Test and remove Polaris ReactTest and remove Polaris React

Test a query with no matches, clear it, and verify that the controls and results update together. Confirm that the empty state doesn't replace loading or error feedback and remains usable at narrow widths.

Don't remove @shopify/polaris while another component still imports it. Once all call sites are migrated, remove the package and its provider-level setup, then run the app's full test suite.


Migrating EmptySearchResult

import {useState} from 'react';

export function EmptySearchResultMigrationExample() {
const [query, setQuery] = useState('snowboard boots');

return (
<s-stack gap="base">
<s-search-field
label="Search products"
value={query}
onInput={(event) => setQuery(event.currentTarget.value)}
/>
<s-empty-state heading={`No products found for “${query}”`}>
<s-icon slot="graphic" type="search" />
<s-text slot="subheading">
Try another search or clear the current query.
</s-text>
<s-button
slot="primary-action"
variant="primary"
onClick={() => setQuery('')}
>
Clear search
</s-button>
</s-empty-state>
</s-stack>
);
}
import {EmptySearchResult} from '@shopify/polaris';


export function EmptySearchResultMigrationExample() {

return (
<EmptySearchResult title="No products found" description="Try changing the filters." withIllustration />
);
}

Preview


Was this page helpful?