
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@ds-kit/autocomplete
Advanced tools
title: "Autocomplete" slug: "/packages/autocomplete" category: "control" componentNames:
The autocomplete component gives users suggestions when choosing one or more values from a predefined list. It should be used where users have to select from a longer, searchable list of items.
To see the autocomplete component in action, check out the input patterns.
import Autocomplete from "@ds-kit/autocomplete"
For the most basic example, pass in a list of objects with a value
and a label
key to the autocomplete.
<>
<Autocomplete
options={[
{ value: "AGO", label: "Angola" },
{ value: "COL", label: "Colombia" },
{ value: "SWE", label: "Sweden" },
{ value: "TZA", label: "Tanzania" },
]}
mb="12rem"
/>
</>
For long list of options, use virtualized version of Autocomplete to maintain performance.
import { AutocompleteVirtualized } from "@ds-kit/autocomplete"
<AutocompleteVirtualized
options={new Array(5000).fill().map((d, i) => ({
value: `${i}`,
label: !i
? `Element with a very very very long label or even much longer one #${i}`
: `Element #${i}`,
}))}
mb="22rem"
/>
The autocomplete can take a raised
prop to make it stand out a bit more on a page. Use the raised version of the autocomplete when placing the autocomplete on colored backgrounds.
<Div bg="green.400" py="2rem" px="1.5rem">
<Autocomplete
raised
options={[
{ value: "AGO", label: "Angola" },
{ value: "COL", label: "Colombia" },
{ value: "SWE", label: "Sweden" },
{ value: "TZA", label: "Tanzania" },
]}
mb="12rem"
/>
</Div>
<>
<Autocomplete
isMulti
options={[
{ value: "AGO", label: "Angola" },
{ value: "COL", label: "Colombia" },
{ value: "SWE", label: "Sweden" },
{ value: "TZA", label: "Tanzania" },
]}
mb="12rem"
/>
</>
In the case of very long labels, you can use the valueMaxWidth
prop to limit the size of the selected value containers in the multiselect.
<>
<Autocomplete
isMulti
valueMaxWidth="8rem"
options={[
{ value: "AGO", label: "Angola" },
{ value: "DRC", label: "Democratic Republic of the Congo" },
{ value: "COL", label: "Colombia" },
{ value: "SWE", label: "Sweden" },
{ value: "TZA", label: "Tanzania" },
]}
mb="14rem"
/>
</>
Use the size
prop to determine the overall size of the autocomplete. The available options (sm
, md
, lg
) are aligned with other control elements, such as buttons and textfields.
<>
<Autocomplete
isMulti
size="lg"
options={[
{ value: "AGO", label: "Angola" },
{ value: "COL", label: "Colombia" },
{ value: "SWE", label: "Sweden" },
{ value: "TZA", label: "Tanzania" },
]}
mb="14rem"
/>
<Autocomplete
isMulti
size="md"
options={[
{ value: "AGO", label: "Angola" },
{ value: "COL", label: "Colombia" },
{ value: "SWE", label: "Sweden" },
{ value: "TZA", label: "Tanzania" },
]}
mb="12rem"
/>
<Autocomplete
isMulti
size="sm"
options={[
{ value: "AGO", label: "Angola" },
{ value: "COL", label: "Colombia" },
{ value: "SWE", label: "Sweden" },
{ value: "TZA", label: "Tanzania" },
]}
mb="10rem"
/>
</>
FAQs
Autocomplete component
The npm package @ds-kit/autocomplete receives a total of 10 weekly downloads. As such, @ds-kit/autocomplete popularity was classified as not popular.
We found that @ds-kit/autocomplete demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.