
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
naked-form-select
Advanced tools
Completely basic styled form selects to give developers the freedom to customize form selects for their projects
Use this package to style form selects that adds minimal markup and requires minimal css. Naked Form Select supports single and multi-select as well as has an option to turn on keyword search. It is written in Javascript and requires no other dependencies.
I've provided a simple demo in the demo folder.
• Install with npm: npm install naked-form-select
"browserslist": [
"> 1%",
"last 2 versions",
"ie >= 11"
]
Include the files in the dist/js/ie11-polyfills as this plugin uses forEach, Array.from, and closest.
Initialize by passing in your selector. For example: nakedFormSelect('select')
To enable multi-select, just make sure your <select> has the multiple property, ex) <select multiple>
Add data-multiple-keyword to <select multiple> in order to control the verbiage used in the label when multiple options are selected. For example:
<select data-multiple-keyword="donut" multiple>
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select>
If option 1 is selected, the label will read 'Option 1'. However, if Option 1 and 2 are selected, the label will read '2 donuts selected'. The keyword provided is turned plural so I recommend that you enter in the singular version of your noun.
Add data-label="true" to any select (single or multiple) in order to set the default verbiage in the label to the text content to the first option but while excluding the first option from the dropdown itself. For example:
<select data-label="true">
<option>Choose a fruit</option>
<option>Banana</option>
<option>Orange</option>
<option>Apple</option>
</select>
Will result in an output that looks like this (the following is not the exact markup generated by naked form select, it is simplified for the example):
<button>Choose a fruit</button>
<ul>
<li>Banana</li>
<li>Orange</li>
<li>Apple</li>
</ul>
Enabling keyword search adds an input with a button to the options dropdown. The options are reduced based off of the matching characters entered into the input by the user. In addition to the 'on' option, there is also a placeholder option in which you can control the input's placeholder text.
Enable keyword search for your select by the following example:
nakedFormSelect('select', {
keywordSearch: {
on: true,
placeholder: 'Enter keyword'
}
});
Add a submit button to the bottom of your dropdown list by the following example:
nakedFormSelect('select', {
submitBtn: {
on: true,
text: 'Submit this form'
}
});
It will submit the parent form.
Query target select elements within a certain context. This option accepts both a value and a boolean property to query document. For instance, reference Example #4 in the demo.html file. If you want to initialize select elements with a class of .example-4 within a containing element with a class of .section-with-context, you would do so like this:
nakedFormSelect('.example-4', {
context: {
value: '.section-with-context',
queryDocument: true
}
});
This essentially accomplishes what the context parameter in jQuery selectors does.
I specifically created the 'queryDocument' option for the Drupal projects I work on to take advantage of the context variable paired with Drupal Behaviors. So, if this option is turned on (default is 'false'), context.value will be queried intead of document.
{
context = {
value: undefined,
queryDocument: false
},
keywordSearch = {
on: false,
placeholder: undefined
},
submitBtn = {
on: false,
text: undefined
}
}
Copyright (C) 2019-2020 Sarah Ferguson.
Licensed under the MIT license.
FAQs
Completely basic styled form selects to give developers the freedom to customize form selects for their projects
We found that naked-form-select demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.