Security News
UK Officials Consider Banning Ransomware Payments from Public Entities
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
@rmwc/select
Advanced tools
Menus display a list of choices on a transient sheet of material.
Selects come in three different styles: standard,outlined, and enhanced.
Standard
<Select label\="Standard" options\={\['Cookies', 'Pizza', 'Icecream'\]} />
Outlined
<Select
label\="Outlined"
outlined
options\={\['Cookies', 'Pizza', 'Icecream'\]}
/>
Enhanced
<Select
label\="Enhanced"
enhanced
options\={\['Cookies', 'Pizza', 'Icecream'\]}
/>
Enhanced renderToPortal
<Select
label\="Enhanced"
enhanced\={{ renderToPortal: true, anchorCorner: 'topLeft' }}
options\={\['Cookies', 'Pizza', 'Icecream'\]}
/>
With Options
<Select
label\="With Icon"
defaultValue\="Pizza"
helpText\="Choose your favorite snack..."
icon\="favorite"
options\={\['Cookies', 'Pizza', 'Icecream'\]}
/>
Required
<Select
label\="Required"
required
options\={\['Cookies', 'Pizza', 'Icecream'\]}
/>
Invalid
<Select
label\="Invalid"
invalid
options\={\['Cookies', 'Pizza', 'Icecream'\]}
/>
Disabled
<Select
label\="Disabled"
disabled
options\={\['Cookies', 'Pizza', 'Icecream'\]}
/>
The Select component has the same behaviors as a native HTML select and be both controlled and uncontrolled.
Controlled
function () {
const \[value, setValue\] \= React.useState('Cookies');
return (
<Select
label\="Controlled"
options\={\['Cookies', 'Pizza', 'Icecream'\]}
value\={value}
onChange\={(evt) \=> setValue(evt.currentTarget.value)}
/>
);
}
Uncontrolled
<Select
label\="Uncontrolled"
options\={\['Cookies', 'Pizza', 'Icecream'\]}
defaultValue\="Cookies"
onChange\={(evt) \=> console.log(evt.currentTarget.value)}
/>
To fit common use cases, RMWC Select provides a data driven method for rendering select menus. There are multiple formats you can pass data in, use the one that best fits your requirements. To make your label not float by default and to have an unselected blank value, set the placeholder
prop to a blank string.
Formatted Options
function Example() {
// A controlled select Using a formatted array of options
const options \= \[
{
label: 'Cookies',
value: '1'
},
{
label: 'Pizza',
value: '2',
/\*\* Any additional items will be passed to the
child ListItem as props \*/
'aria-disabled': true,
tabIndex: \-1
},
{
label: 'Icecream',
value: '3'
}
\];
return <Select label\="Array" options\={options} />;
}
Value => Label Map
<Select
label\="Object map"
options\={{ '1': 'Cookies', '2': 'Pizza', '3': 'Icecream' }}
/>
Array
<Select
label\="Simple Array"
placeholder\="\-- Select One --"
options\={\['Cookies', 'Pizza', 'Icecream'\]}
/>
If you want full control over the child ListItems
, you can manually build the list yourself.
Manually Built
<Select label\="Manual" defaultValue\="Cookies"\>
<option value\="Cookies"\>Cookies</option\>
<option value\="Pizza"\>Pizza</option\>
<option value\="Icecream"\>Icecream</option\>
</Select\>
Both native and enhanced Selects can contain option groups. Just nest additional options arrays in your data.
Option Groups: Formatted
<Select
label\="Formatted"
enhanced
options\={\[
{
label: 'Dinner',
options: \[
{
label: 'Pizza',
value: '2'
}
\]
},
{
label: 'Dessert',
options: \[
{
label: 'Cookies',
value: '1'
},
{
label: 'Icecream',
value: '3'
}
\]
}
\]}
/>
Options Groups: Manually Built
<Select label\="Manually Built"\>
<optgroup label\="Dinner"\>
<option value\="Pizza"\>Pizza</option\>
</optgroup\>
<optgroup label\="Dessert"\>
<option value\="Cookies"\>Cookies</option\>
<option value\="Icecream"\>Icecream</option\>
</optgroup\>
</Select\>
FAQs
RMWC Select component
The npm package @rmwc/select receives a total of 4,262 weekly downloads. As such, @rmwc/select popularity was classified as popular.
We found that @rmwc/select demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.