
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
coherent-gameface-dropdown
Advanced tools
The gameface-dropdown is part of the Gameface custom components suite.
npm i coherent-gameface-dropdown
<script src="./node_modules/coherent-gameface-dropdown/dist/dropdown.production.min.js"></script>
<gameface-dropdown></gameface-dropdown>
To add options to the dropdown use the dropdown-option custom element:
<gameface-dropdown>
<dropdown-option>Cat</dropdown-option>
<dropdown-option>Dog</dropdown-option>
<dropdown-option>Giraffe</dropdown-option>
<dropdown-option>Lion</dropdown-option>
</gameface-dropdown>
To manually select an option use the dropdown value
setter.
For example - to select the Giraffe option from the dropdown above call:
const dropdown = document.getElementById('my-dropdown');
dropdown.value = 'Giraffe';
This is all! Load the file in Gameface to see the gameface-dropdown.
If you wish to import the GamefaceDropdown using JavaScript you can remove the script tag and import it like this:
import { GamefaceDropdown } from 'coherent-gameface-dropdown';
or simply
import 'coherent-gameface-dropdown';
Note that this approach requires a module bundler like Webpack or Rollup to resolve the modules from the node_modules folder.
To enable multiple selection add a multiple
attribute to the gameface-dropdown:
<gameface-dropdown class="gameface-dropdown-component" multiple>
<dropdown-option>Cat1</dropdown-option>
<dropdown-option>Parrot</dropdown-option>
</gameface-dropdown>
By default the multiple select will have its options list expanded and it won't have
a header. If you would like to have a dropdown that looks like a single select, but
supports multiple selected elements - add the collapsable
attribute along with the multiple
attribute:
<gameface-dropdown class="gameface-dropdown-component" multiple collapsable>
<dropdown-option>Cat1</dropdown-option>
<dropdown-option>Parrot</dropdown-option>
</gameface-dropdown>
This is not a standard HTML select multiple. It is a custom HTML element that enables you to define a list of options.
multiple
attribute makes it possible to select more than one option using the Ctrl key and the mouse.
disabled
attribute to gameface-dropdown or a dropdown-option to disable it.selected
attribute to any dropdown-option to pre-select it.These are some of the differences to the standard select that are partially or not yet supported:
You can modify the dropdown and its options using HTML attributes. The gameface-dropdown
supports:
Also these options are added as setters to the dropdown so you can runtime change the dropdown using JavaScript. For example:
dropdown.multiple = true;
dropdown.collapsable = true;
dropdown.disabled = false;
The dropdown-option
supports:
Note that attempting to remove an attribute from an option that does not have this attribute will have no effect! For example an option could be selected and not have the selected attribute, as selecting an option using the mouse will update only its internal selected property.
To add or remove an attribute use the setAttribute or the removeAttribute method.
<link rel="stylesheet" href="coherent-gameface-components-theme.css">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="node_modules/coherent-gameface-scrollable-container/style.css">
<link rel="stylesheet" href="node_modules/coherent-gameface-slider/styles/horizontal.css">
<link rel="stylesheet" href="node_modules/coherent-gameface-slider/styles/vertical.css">
To overwrite the default styles, simply create new rules for the class names that you wish to change and include them after the default styles.
FAQs
A component for Coherent Labs Gameface.
We found that coherent-gameface-dropdown demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.