Search provides the ability to narrow down data using a specialized TextField.

Importing

The component can be imported via:

import { Search } from '@customerio/pluma-components/react';

Usage

Loading editor

Search Trigger Options

By default, the PlumaSearch component will not trigger a search. You can enable search actions with the following options:

  • shouldSearchOnBlur (boolean): Triggers a search when the input loses focus. Defaults to false.
  • shouldSearchOnDebounce (number): Triggers a search after the specified debounce interval (in milliseconds). Must be greater than 0 to enable. Defaults to 0.
  • shouldSearchOnInput (boolean): Triggers a search whenever the input value changes. Defaults to false.
  • shouldSearchOnEnter (boolean): Triggers a search when the Enter key is pressed. Defaults to false.
  • shouldSearchOnClear (boolean): Triggers a search when the input is cleared via the clear button. Defaults to false.

For server-side search, you should use shouldSearchOnEnter and shouldSearchOnClear. Check with the back-end team and, if there is not a performance concern with extra queries, consider using shouldSearchOnDebounce for a better user experience.

For client-side search, you should use shouldSearchOnInput and shouldSearchOnClear. If it is a large dataset, consider using shouldSearchOnDebounce for a better user experience.

Accessibility

The PlumaSearch component inherits accessibility features from the TextField component, including teh requirement for ariaLabel, label, or ariaLabelledby.

Errors

The PlumaSearch component accepts an isInvalid prop, which will render the input in an error state:

Loading editor

It is also highly recommended to provide an error message when the input is invalid. This will render below the input:

Loading editor

Icons

While you can set the icon, the search icon is used by default and should not be overridden without a very good reason from a designer.

Loading editor

Customizing labels

If a string label is not sufficient, a component can be used to render the label.

In React, the label prop accepts any ReactNode.

Loading editor

Customizing descriptions

If a string description is not sufficient, a component can be used to render the description.

In React, the description prop accepts any ReactNode.

Loading editor

Customizing errors

If a string error is not sufficient, a component can be used to render the error.

In React, the error prop accepts any ReactNode.

Loading editor

API

Default:'input'

What element or component should be rendered.

Additional classes to be applied to the top-level container. This is necessary as an argument in Ember, where we apply splattributes on the "input" itself, which means we can't pass a custom class to the containing element the classic way.

The name of an icon (from Pluma Icons) to be rendered on the left side of the input.

Whether the input should render in an "active" styled state.

Whether the input should show a loading spinner.

The blur event handler for the input element.

The change event handler for the input element.

Called when the clear button is clicked.

The focus event handler for the input element.

The input event handler for the input element.

The function called when the search should be done

Any changes to the value for the search input

Placeholder text to show inside the field.

Whether to search when the search input is blurred.

Whether to search when the clear button is pressed.

Whether to search on a specific debounced interval, must be greater than 0 to trigger a search.

Whether to search when Enter is pressed.

Whether to search when the value changes.

Default:md

The size of the input element.

The type of input that should be rendered. Defaults to text.

Pluma internal property to set a component name used for logging. Only use if building a custom component that wraps this one and need to make it more obvious where errors, for example, come from.

Additional classes to be applied to the div that wraps the input element.

The current value.

Ember only: a modifier to apply on the input's wrapper element.

React only: a ref to the input's wrapper element.