Text filter

Case- and accent-insensitive contains, for filtering a list as the user types.

Reach for it to filter options while the user types. The helpers are pure: no DOM at import time or in the call path, so they run on the server and in tests. Each result below is computed when the page is built, by running the call shown.

Import

import { textContains, type TextFilterSensitivity } from '@ecopages/radiant-ui/helpers';

Sensitivity

base (default) ignores case and accents, accent ignores case only, case is a literal substring match. An empty query matches everything.

CallResult
textContains('Crème brûlée', 'creme')true
textContains('Crème brûlée', 'creme', 'accent')false
textContains('Crème brûlée', 'crème', 'accent')true
textContains('Crème brûlée', 'brûl', 'case')true
textContains('Crème brûlée', 'brul', 'case')false
textContains('Crème brûlée', '')true