Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@chakra-ui/select
Advanced tools
The Select component is a component that allows users pick a value from predefined options.
Ideally, it should be used when there are more than 5 options, otherwise you might consider using a radio group instead.
yarn add @chakra-ui/select
# or
npm i @chakra-ui/select
import { Select } from "@chakra-ui/select"
<Select placeholder="A simple select component">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</Select>
Pass the isDisabled
prop to put the select component in an invalid state
<Select placeholder="Select option" isDisabled>
<option value="Option 1">Option 1</option>
<option value="Option 2">Option 2</option>
<option value="Option 3">Option 3</option>
</Select>
Pass the isInvalid
prop to put the select component in an invalid state
<Select placeholder="Select option" isInvalid>
<option value="Option 1">Option 1</option>
<option value="Option 2">Option 2</option>
<option value="Option 3">Option 3</option>
</Select>
Control the visual appearance of the select component by passing the variant
prop.
The following values are allowed: outline, filled, flushed, unstyled
<Stack>
<Select placeholder="Select option" variant="outline">
<option value="Option 1">Option 1</option>
<option value="Option 2">Option 2</option>
<option value="Option 3">Option 3</option>
</Select>
<Select placeholder="Select option" variant="filled">
<option value="Option 1">Option 1</option>
<option value="Option 2">Option 2</option>
<option value="Option 3">Option 3</option>
</Select>
<Select placeholder="Select option" variant="flushed">
<option value="Option 1">Option 1</option>
<option value="Option 2">Option 2</option>
<option value="Option 3">Option 3</option>
</Select>
<Select placeholder="Select option" variant="unstyled">
<option value="Option 1">Option 1</option>
<option value="Option 2">Option 2</option>
<option value="Option 3">Option 3</option>
</Select>
</Stack>
Pass the size
prop to change the size and height of the select component.
The following values are allowed: sm, md, lg
<Stack spacing={4}>
{["sm", "md", "lg"].map((size) => (
<Select key={size} placeholder="Select option" size={size}>
<option value="Option 1">Option 1</option>
<option value="Option 2">Option 2</option>
<option value="Option 3">Option 3</option>
</Select>
))}
</Stack>
const ControlledSelectExample = () => {
const [value, setValue] = React.useState("")
const handleChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
setValue(event.target.value)
}
return (
<Select
value={value}
onChange={handleChange}
placeholder="Controlled select"
>
<option value="Option 1">Option 1</option>
<option value="Option 2">Option 2</option>
<option value="Option 3">Option 3</option>
</Select>
)
}
Pass the icon
prop to change the arrow icon of the select component to a
custom icon.
You also have access to the iconSize
prop to change the size of the custom
arrow icon.
const CustomSelectIconExample = () => {
const SelectIcon = () => (
<Icon viewBox="0 0 24 24">
<path
fill="currentColor"
d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"
/>
</Icon>
)
return <Select icon={SelectIcon} placeholder="Placeholder" size="md" />
}
Pass the focusBorderColor
prop to change the border color of the select
component in the focused state.
Pass the errorBorderColor
prop to change the border color of the select
component in the invalid state.
The value of these props can be set to a color in the theme object, or a raw CSS value.
<Stack>
<Select focusBorderColor="lime" placeholder="Here is a sample placeholder" />
<Select
isInvalid
errorBorderColor="crimson"
placeholder="Here is a sample placeholder"
/>
</Stack>
Even though the select comes with predefined styles, you can override pretty much any property. Here's we'll override the background color.
<Select
color="white"
borderColor="tomato"
backgroundColor="tomato"
placeholder="Woohoo! A new background color!"
/>
FAQs
description
We found that @chakra-ui/select demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.