Skip to main content

Search

Library
UDS Base
Repository
github.com/telus/universal-design-system
Package
npmjs.com/package/@telus-uds/components-base
Package version
1.6.1
Loading...

Introduction

import { Search } from '@telus-uds/components-base'

Use Search for text-based searching or filtering with optional autocomplete functionality.

Guidance

Search includes a clear button, which will appear as text is entered and pressing it will cause the input's internal state value to be set to an empty string.

Updating parent on changes

Use the onChange prop to react to value changes and the onSubmit prop to react on search submission.

Loading...

Search is based on TextInput, plus two custom buttons. Unlike other input components, however, this component may only be used as "uncontrolled" where the content of the text input is set only by user interaction. The search text state is managed internally based on user input and may not be "controlled" by a parent component.

Accessibility

Use the copy prop to select english or french copy for the accessibility labels. You may also pass in a custom dictionary object.

Props

NameTypeDefaultDescription
initialValuestring''Use this to set the initial value of the search input. Updating `initialValue` will **not** update the actual value.
placeholderstring'Search'Label rendered in the search input when it has no value.
copyunion'en'Select english or french copy for the accessible labels. You may also pass in a custom dictionary object.
inactiveboolDisables all user interactions with the search input.
onChangefuncUse to react upon search input's value changes. Will receive the searched value as an argument.
onSubmitfuncTriggered when the search input is submitted, either by pressing the submit button, "Enter" key on web, or "Search" key in a mobile keyboard.
onClearfuncTriggered when the clear button is pressed.
accessibilityLabelstringUse to provide an accessible label for the input (visually hidden).
tokenscustomSystem tokens prop, see tokens for more details
variantobjectOfSystem variant prop, see variants for more details