---
title: Search
---

import LibraryInfo from '@theme/LibraryInfo'
import { ExternalCodeBlock, Feedback, TokensTable, PropsTable } from '../../src/components'
import { Search, List, StackView, TextButton, Typography } from '@telus-uds/components-web'
import { Search as BaseDocs } from 'docs/@telus-uds/components-base'
import AvailableOnBoth from '../../partials/_platform-considerations-both.mdx'

# Search

<LibraryInfo figmaLink="https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2F4zJn2Qn6uXOqPP1GVDipy6%2F%25F0%259F%258D%2580-Allium-Components%3Fnode-id%3D3397%253A35473" />

```jsx live
<Search />
```

## Introduction

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

[Follow the appropriate instructions](importing-components) to add this component in to your app.

## 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.

```jsx live
function SearchWithCallbacks() {
  const [value, setValue] = useState('')
  const [submitted, setSubmitted] = useState()

  return (
    <StackView space={2}>
      <Search onChange={setValue} onSubmit={setSubmitted} />

      <Typography>
        Current value is: <Typography variant={{ bold: true }}>{value}</Typography>
      </Typography>
      <Typography>
        Submitted value was: <Typography variant={{ bold: true }}>{submitted}</Typography>
      </Typography>
    </StackView>
  )
}
```

### Controlled usage

Pass `value` and `onChange` to control the search input from a parent.

:::caution
Allium-branded autocomplete suggestions for Search are still under design consideration.

The below example is **only** an example of the capabilities of Search props, and not an example of how such a feature should look or behave.

Please [contact DPA](https://telusdigital.slack.com/archives/CDQ6P8VNU) for advice on design, user experience and accessibility of similar features.
:::

<ExternalCodeBlock
  file="search-controlled"
  scope={{ Search, List, StackView, TextButton, Typography }}
/>

### Accessibility

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

### Platform considerations

<AvailableOnBoth />

## Props

<PropsTable base={BaseDocs} />

## Tokens

<TokensTable base={BaseDocs} component="Search" />

## Variants

This component has no visual variants but its appearance may change based on the `inactive` prop:

```jsx live
<Search inactive />
```

## Feedback

<Feedback component="Search" />
