import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';
import { TextFieldBase, TextField } from '..';
import { TextFieldSearch } from './text-field-search';
# TextFieldSearch
The `TextFieldSearch` allows users to enter text to search
## Props
The `TextFieldSearch` accepts all props below as well as all [Box](/docs/ui-components-ui-box-box-stories-js--default-story#props) component props
`TextFieldSearch` accepts all [TextField](/docs/ui-components-component-library-text-field-text-field-stories-js--default-story#props)
component props
`TextFieldSearch` accepts all [TextFieldBase](/docs/ui-components-component-library-text-field-base-text-field-base-stories-js--default-story#props)
component props
### Clear Button On Click
`TextFieldSearch` displays a clear button when text is entered into the input. Use the `clearButtonOnClick` prop to pass an `onClick` event handler to clear the value of the input. To hide the clear button, pass `false` to the `showClearButton` prop.
The clear button uses [ButtonIcon](/docs/ui-components-component-library-button-icon-button-icon-stories-js--default-story) and accepts all props from that component.
**NOTE: The `showClearButton` only works with a controlled input.**
```jsx
import { TextFieldSearch } from '../../component-library';
const [value, setValue] = useState('show clear');
const handleOnChange = (e) => {
setValue(e.target.value);
};
const handleOnClear = () => {
setValue('');
};
;
```
### Clear Button Props
Use the `clearButtonProps` to access other props of the clear button.
```jsx
import React, { useState } from 'react';
import {
SIZES,
COLORS,
BORDER_RADIUS,
} from '../../../helpers/constants/design-system';
import { TextFieldSearch } from '../../component-library';
const [value, setValue] = useState('show clear');
const handleOnChange = (e) => {
setValue(e.target.value);
};
const handleOnClear = () => {
setValue('');
};
;
```