AutoComplete

The AutoComplete component is a versatile and styled input field. It offers features like theming, validation, error handling, and the capability to prepend or append icons.

Usage

Basic AutoComplete

Simple AutoComplete example

<AutoComplete placeholder="Name" suggestions={['Apple', 'Banana']} />

Variants

Using the ghost, solid, outlined variant prop.

<Flex direction="column">
<AutoComplete block placeholder="Address" suggestions={['Apple', 'Banana']} variant="ghost" />
<AutoComplete block placeholder="Address" suggestions={['Apple', 'Banana']} variant="solid" />
<AutoComplete block placeholder="Address" suggestions={['Apple', 'Banana']} variant="outlined" />
</Flex>

Shadow

Using the shadow prop we can adjust shadow values for the component.

<Flex direction="column">
<AutoComplete shadow="4" placeholder="Name" suggestions={['Apple', 'Banana']} />
</Flex>

AutoComplete with Icons

AutoComplete with prepend and append icons

<AutoComplete suggestions={['Apple', 'Banana']} placeholder="Search" iconPrepend={<Icon type="Search" />} iconAppend={<Icon type="X" />} />

Error Handling

With custom error messages

<AutoComplete suggestions={['Apple', 'Banana']} placeholder="Email" required pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$" errorMessage="Enter a valid email address." />

Theming and Styling

Themed AutoComplete

<AutoComplete suggestions={['Apple', 'Banana']} placeholder="Password" color="blue" radius="full" />

API

Props

PropTypeDefaultRequired
suggestionsArray<string>-Yes
variant'solid' | 'ghost' | 'outlined'--
placeholderstring--
iconPrependReactNode--
iconAppendReactNode--
blockboolean--
patternstring--
errorMessagestring--
onChange(e: ChangeEvent<HTMLInputElement>) => void--
onSubmit() => void--
colorThemeAccentColor--
size'xlarge' | 'large' | 'medium' | 'small''medium'-
radiusThemeRadius--
shadowThemeShadow--
Pagination
Previous
Checkbox
Next