HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URL's added here will be added as <link>
s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<label for="select-el" class="combo-label">Native select element</label>
<select id="select-el" class="combo combo-input" multiple>
<option>Apple</option>
<option>Apricot</option>
<option>Banana</option>
<option>Blackberry</option>
<option>Blueberry</option>
<option>Cantaloupe</option>
<option>Cherry</option>
<option>Date</option>
<option>Durian</option>
<option>Eggplant</option>
<option>Fig</option>
<option>Grape</option>
<option>Guava</option>
<option>Huckleberry</option>
</select>
<label for="combo1" class="combo-label">Multiselect with comma-separated values</label>
<div class="combo js-csv">
<div role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-owns="listbox1" class="input-wrapper">
<input
aria-activedescendant=""
aria-autocomplete="list"
id="combo1"
class="combo-input"
type="text">
</div>
<div class="combo-menu" role="listbox" aria-multiselectable="true" id="listbox1"></div>
</div>
<label id="combo2-label" class="combo-label">Multiselect with buttons</label>
<span id="combo2-remove" style="display: none">remove</span> <!-- used as descriptive text for option buttons; if used within the button text itself, it ends up being read with the input name -->
<ul class="selected-options" id="combo2-selected"></ul>
<div class="combo js-multi-buttons">
<div role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-owns="listbox2" class="input-wrapper">
<input
aria-activedescendant=""
aria-autocomplete="list"
aria-labelledby="combo2-label combo2-selected"
id="combo2"
class="combo-input"
type="text">
</div>
<div class="combo-menu" role="listbox" aria-multiselectable="true" id="listbox2"></div>
</div>
<label id="combo3-label" class="combo-label">Multiselect with inline buttons</label>
<span id="combo3-remove" style="display: none">remove</span> <!-- used as descriptive text for option buttons; if used within the button text itself, it ends up being read with the input name -->
<div class="combo js-inline-buttons">
<div role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-owns="listbox3" class="input-wrapper multiselect-inline">
<ul class="selected-options" aria-live="assertive" aria-atomic="false" aria-relevant="additions removals" id="combo3-selected"></ul>
<input
aria-activedescendant=""
aria-autocomplete="list"
aria-labelledby="combo3-label combo3-selected"
id="combo3"
class="combo-input"
type="text">
</div>
<div class="combo-menu" role="listbox" aria-multiselectable="true" id="listbox3"></div>
</div>
*, *::before, *::after {
box-sizing: border-box;
}
body {
background-color: #f5f5f5;
font-family: "Segoe UI", SegoeUI, "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 120%;
line-height: 1.4;
margin: 0;
padding: 2em;
}
.combo {
display: block;
margin-bottom: 1.5em;
max-width: 400px;
position: relative;
}
.combo::after {
border-bottom: 2px solid rgba(0,0,0,.5);
border-right: 2px solid rgba(0,0,0,.5);
content: '';
display: block;
height: 12px;
pointer-events: none;
position: absolute;
right: 16px;
top: 50%;
transform: translate(0, -65%) rotate(45deg);
width: 12px;
}
.input-wrapper {
border-radius: 4px;
}
.combo-input {
background-color: #f5f5f5;
border: 2px solid rgba(0,0,0,.5);
border-radius: 4px;
display: block;
font-size: 1em;
min-height: calc(1.4em + 26px);
padding: 12px 16px 14px;
text-align: left;
width: 100%;
}
select.combo-input {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
.open .combo-input {
border-radius: 4px 4px 0 0;
}
.combo-input:focus {
border-color: #0067b8;
box-shadow: 0 0 4px 2px #0067b8;
outline: 5px solid transparent;
}
.combo-label {
display: block;
font-size: 20px;
font-weight: 100;
margin-bottom: 0.25em;
}
.combo-menu {
background-color: #f5f5f5;
border: 1px solid rgba(0,0,0,.42);
border-radius: 0 0 4px 4px;
display: none;
max-height: 300px;
overflow-y:scroll;
left: 0;
position: absolute;
top: 100%;
width: 100%;
z-index: 100;
}
.open .combo-menu {
display: block;
}
.combo-option {
padding: 10px 12px 12px;
}
.combo-option.option-current,
.combo-option:hover {
background-color: rgba(0,0,0,0.1);
}
.combo-option.option-selected {
padding-right: 30px;
position: relative;
}
.combo-option.option-selected::after {
border-bottom: 2px solid #000;
border-right: 2px solid #000;
content: '';
height: 16px;
position: absolute;
right: 15px;
top: 50%;
transform: translate(0, -50%) rotate(45deg);
width: 8px;
}
/* multiselect list of selected options */
.selected-options {
list-style-type: none;
margin: 0;
max-width: 400px;
padding: 0;
}
.selected-options li {
display: inline-block;
margin-bottom: 5px;
}
.remove-option {
background-color: #6200ee;
border: 1px solid #6200ee;
border-radius: 3px;
color: #fff;
font-size: 0.75em;
font-weight: bold;
margin-bottom: 6px;
margin-right: 6px;
padding: 0.25em 1.75em 0.25em 0.25em;
position: relative;
}
.remove-option:focus {
border-color: #baa1dd;
box-shadow: 0 0 3px 1px #6200ee;
outline: 3px solid transparent;
}
.remove-option::before,
.remove-option::after {
border-right: 2px solid #fff;
content: "";
height: 1em;
right: 0.75em;
position: absolute;
top: 50%;
width: 0;
}
.remove-option::before {
transform: translate(0, -50%) rotate(45deg);
}
.remove-option::after {
transform: translate(0, -50%) rotate(-45deg);
}
.multiselect-inline {
align-items: center;
background-color: #f5f5f5;
border: 2px solid rgba(0,0,0,.42);
border-radius: 4px;
display: flex;
flex-wrap: wrap;
min-height: calc(1.4em + 26px);
padding: 12px 16px 14px;
}
.multiselect-inline .selected-options {
flex: 0 1 auto;
}
.multiselect-inline .selected-options li {
margin-bottom: 0;
}
.multiselect-inline .combo-input {
border: none;
flex: 1 1 35%;
min-height: calc(1.4em - 2px);
padding: 0;
}
.multiselect-inline .combo-input:focus {
box-shadow: none;
outline: none;
}
.multiselect-inline:focus-within {
box-shadow: 0 0 3px 2px #0067b8;
outline: 5px solid transparent;
}
// options for all examples
const options = ['Apple', 'Apricot', 'Banana', 'Blackberry', 'Blueberry', 'Cantaloupe', 'Cherry', 'Date', 'Durian', 'Eggplant', 'Fig', 'Grape', 'Guava', 'Huckleberry'];
/*
* Helper constants and functions
*/
// make it easier for ourselves by putting some values in objects
// in TypeScript, these would be enums
const Keys = {
Backspace: 'Backspace',
Clear: 'Clear',
Down: 'ArrowDown',
End: 'End',
Enter: 'Enter',
Escape: 'Escape',
Home: 'Home',
Left: 'ArrowLeft',
PageDown: 'PageDown',
PageUp: 'PageUp',
Right: 'ArrowRight',
Space: ' ',
Tab: 'Tab',
Up: 'ArrowUp'
}
const MenuActions = {
Close: 0,
CloseSelect: 1,
First: 2,
Last: 3,
Next: 4,
Open: 5,
Previous: 6,
Select: 7,
Space: 8,
Type: 9
}
// filter an array of options against an input string
// returns an array of options that begin with the filter string, case-independent
function filterOptions(options = [], filter, exclude = []) {
return options.filter((option) => {
const matches = option.toLowerCase().indexOf(filter.toLowerCase()) === 0;
return matches && exclude.indexOf(option) < 0;
});
}
// return an array of exact option name matches from a comma-separated string
function findMatches(options, search) {
const names = search.split(',');
return names.map((name) => {
const match = options.filter((option) => name.trim().toLowerCase() === option.toLowerCase());
return match.length > 0 ? match[0] : null;
})
.filter((option) => option !== null);
}
// return combobox action from key press
function getActionFromKey(key, menuOpen) {
// handle opening when closed
if (!menuOpen && key === Keys.Down) {
return MenuActions.Open;
}
// handle keys when open
if (key === Keys.Down) {
return MenuActions.Next;
}
else if (key === Keys.Up) {
return MenuActions.Previous;
}
else if (key === Keys.Home) {
return MenuActions.First;
}
else if (key === Keys.End) {
return MenuActions.Last;
}
else if (key === Keys.Escape) {
return MenuActions.Close;
}
else if (key === Keys.Enter) {
return MenuActions.CloseSelect;
}
else if (key === Keys.Backspace || key === Keys.Clear || key.length === 1) {
return MenuActions.Type;
}
}
// get index of option that matches a string
function getIndexByLetter(options, filter) {
const firstMatch = filterOptions(options, filter)[0];
return firstMatch ? options.indexOf(firstMatch) : -1;
}
// get updated option index
function getUpdatedIndex(current, max, action) {
switch(action) {
case MenuActions.First:
return 0;
case MenuActions.Last:
return max;
case MenuActions.Previous:
return Math.max(0, current - 1);
case MenuActions.Next:
return Math.min(max, current + 1);
default:
return current;
}
}
// check if an element is currently scrollable
function isScrollable(element) {
return element && element.clientHeight < element.scrollHeight;
}
// ensure given child element is within the parent's visible scroll area
function maintainScrollVisibility(activeElement, scrollParent) {
const { offsetHeight, offsetTop } = activeElement;
const { offsetHeight: parentOffsetHeight, scrollTop } = scrollParent;
const isAbove = offsetTop < scrollTop;
const isBelow = (offsetTop + offsetHeight) > (scrollTop + parentOffsetHeight);
if (isAbove) {
scrollParent.scrollTo(0, offsetTop);
}
else if (isBelow) {
scrollParent.scrollTo(0, offsetTop - parentOffsetHeight + offsetHeight);
}
}
/*
* Multiselect CSV code
*/
const MultiselectCSV = function(el, options) {
// element refs
this.el = el;
this.comboEl = el.querySelector('[role=combobox]');
this.inputEl = el.querySelector('input');
this.listboxEl = el.querySelector('[role=listbox]');
// data
this.idBase = this.inputEl.id;
this.options = options;
this.filteredOptions = options;
this.selectedOptions = [];
// state
this.activeIndex = 0;
this.open = false;
}
MultiselectCSV.prototype.init = function() {
this.inputEl.addEventListener('input', this.onInput.bind(this));
this.inputEl.addEventListener('blur', this.onInputBlur.bind(this));
this.inputEl.addEventListener('click', () => this.updateMenuState(true));
this.inputEl.addEventListener('keydown', this.onInputKeyDown.bind(this));
this.options.map((option, index) => {
const optionEl = document.createElement('div');
optionEl.setAttribute('role', 'option');
optionEl.id = `${this.idBase}-${index}`;
optionEl.className = index === 0 ? 'combo-option option-current' : 'combo-option';
optionEl.setAttribute('aria-selected', 'false');
optionEl.innerText = option;
optionEl.addEventListener('click', () => { this.onOptionClick(index); });
optionEl.addEventListener('mousedown', this.onOptionMouseDown.bind(this));
this.listboxEl.appendChild(optionEl);
});
}
MultiselectCSV.prototype.filterOptions = function(value, excludeOptions = []) {
this.filteredOptions = filterOptions(this.options, value, excludeOptions);
// hide/show options based on filtering
const options = this.el.querySelectorAll('[role=option]');
[...options].forEach((optionEl) => {
const value = optionEl.innerText;
if (this.filteredOptions.indexOf(value) > -1) {
optionEl.style.display = 'block';
}
else {
optionEl.style.display = 'none';
}
});
}
MultiselectCSV.prototype.onInput = function() {
const curValue = this.inputEl.value;
const currentSearch = curValue.split(',').pop().replace(/^\s+/, '');
const matchingOptions = findMatches(this.options, curValue);
this.updateSelectedOptions(matchingOptions, false);
this.filterOptions(currentSearch, this.selectedOptions);
// if active option is not in filtered options, set it to first filtered option
if (this.filteredOptions.indexOf(this.options[this.activeIndex]) < 0) {
const firstFilteredIndex = Math.max(this.options.indexOf(this.filteredOptions[0]), 0);
this.onOptionChange(firstFilteredIndex);
}
const menuState = this.filteredOptions.length > 0;
if (this.open !== menuState) {
this.updateMenuState(menuState, false);
}
}
MultiselectCSV.prototype.onInputKeyDown = function(event) {
const { key } = event;
const max = this.filteredOptions.length - 1;
const activeFilteredIndex = this.filteredOptions.indexOf(this.options[this.activeIndex]);
const action = getActionFromKey(key, this.open);
switch(action) {
case MenuActions.Next:
case MenuActions.Last:
case MenuActions.First:
case MenuActions.Previous:
event.preventDefault();
const nextFilteredIndex = getUpdatedIndex(activeFilteredIndex, max, action);
const nextRealIndex = this.options.indexOf(this.filteredOptions[nextFilteredIndex]);
return this.onOptionChange(nextRealIndex);
case MenuActions.CloseSelect:
event.preventDefault();
this.updateOption(this.activeIndex);
return this.updateMenuState(false);
case MenuActions.Close:
event.preventDefault();
return this.updateMenuState(false);
case MenuActions.Open:
return this.updateMenuState(true);
}
}
MultiselectCSV.prototype.onInputBlur = function() {
if (this.ignoreBlur) {
this.ignoreBlur = false;
return;
}
if (this.open) {
this.processInputString(this.inputEl.value);
this.updateMenuState(false, false);
}
}
MultiselectCSV.prototype.onOptionChange = function(index) {
this.activeIndex = index;
this.inputEl.setAttribute('aria-activedescendant', `${this.idBase}-${index}`);
// update active style
const options = this.el.querySelectorAll('[role=option]');
[...options].forEach((optionEl) => {
optionEl.classList.remove('option-current');
});
options[index].classList.add('option-current');
if (this.open && isScrollable(this.listboxEl)) {
maintainScrollVisibility(options[index], this.listboxEl);
}
}
MultiselectCSV.prototype.onOptionClick = function(index) {
this.onOptionChange(index);
this.updateOption(index);
this.inputEl.focus();
}
MultiselectCSV.prototype.onOptionMouseDown = function() {
this.ignoreBlur = true;
}
MultiselectCSV.prototype.processInputString = function(inputString) {
const options = findMatches(this.options, inputString);
this.updateSelectedOptions(options, true);
}
MultiselectCSV.prototype.updateOption = function(index) {
const option = this.options[index];
const selectedIndex = this.selectedOptions.indexOf(option);
const isSelected = selectedIndex > -1;
this.filterOptions('');
if (isSelected) {
this.selectedOptions.splice(selectedIndex, 1);
this.updateSelectedOptions(this.selectedOptions, true);
}
else {
this.updateSelectedOptions([...this.selectedOptions, option], true);
}
}
MultiselectCSV.prototype.updateMenuState = function(open, callFocus = true) {
this.open = open;
this.comboEl.setAttribute('aria-expanded', `${open}`);
open ? this.el.classList.add('open') : this.el.classList.remove('open');
callFocus && this.inputEl.focus();
}
MultiselectCSV.prototype.updateSelectedOptions = function(options, setInputValue) {
this.selectedOptions = options;
if (setInputValue) {
this.inputEl.value = this.selectedOptions.join(', ');
}
// update aria-selected
const optionEls = this.el.querySelectorAll('[role=option]');
[...optionEls].forEach((optionEl) => {
const optionSelected = this.selectedOptions.indexOf(optionEl.innerText) > -1;
optionEl.setAttribute('aria-selected', `${optionSelected}`);
optionSelected ? optionEl.classList.add('option-selected') : optionEl.classList.remove('option-selected');
});
this.filterOptions('');
}
// init combo
const csvEl = document.querySelector('.js-csv');
const csvComponent = new MultiselectCSV(csvEl, options);
csvComponent.init();
/*
* Multiselect Combobox w/ Buttons code
*/
const MultiselectButtons = function(el, options) {
// element refs
this.el = el;
this.comboEl = el.querySelector('[role=combobox]');
this.inputEl = el.querySelector('input');
this.listboxEl = el.querySelector('[role=listbox]');
this.idBase = this.inputEl.id;
this.selectedEl = document.getElementById(`${this.idBase}-selected`);
// data
this.options = options;
this.filteredOptions = options;
// state
this.activeIndex = 0;
this.open = false;
}
MultiselectButtons.prototype.init = function() {
this.inputEl.addEventListener('input', this.onInput.bind(this));
this.inputEl.addEventListener('blur', this.onInputBlur.bind(this));
this.inputEl.addEventListener('click', () => this.updateMenuState(true));
this.inputEl.addEventListener('keydown', this.onInputKeyDown.bind(this));
this.options.map((option, index) => {
const optionEl = document.createElement('div');
optionEl.setAttribute('role', 'option');
optionEl.id = `${this.idBase}-${index}`;
optionEl.className = index === 0 ? 'combo-option option-current' : 'combo-option';
optionEl.setAttribute('aria-selected', 'false');
optionEl.innerText = option;
optionEl.addEventListener('click', () => { this.onOptionClick(index); });
optionEl.addEventListener('mousedown', this.onOptionMouseDown.bind(this));
this.listboxEl.appendChild(optionEl);
});
}
MultiselectButtons.prototype.filterOptions = function(value) {
this.filteredOptions = filterOptions(this.options, value);
// hide/show options based on filtering
const options = this.el.querySelectorAll('[role=option]');
[...options].forEach((optionEl) => {
const value = optionEl.innerText;
if (this.filteredOptions.indexOf(value) > -1) {
optionEl.style.display = 'block';
}
else {
optionEl.style.display = 'none';
}
});
}
MultiselectButtons.prototype.onInput = function() {
const curValue = this.inputEl.value;
this.filterOptions(curValue);
// if active option is not in filtered options, set it to first filtered option
if (this.filteredOptions.indexOf(this.options[this.activeIndex]) < 0) {
const firstFilteredIndex = this.options.indexOf(this.filteredOptions[0]);
this.onOptionChange(firstFilteredIndex);
}
const menuState = this.filteredOptions.length > 0;
if (this.open !== menuState) {
this.updateMenuState(menuState, false);
}
}
MultiselectButtons.prototype.onInputKeyDown = function(event) {
const { key } = event;
const max = this.filteredOptions.length - 1;
const activeFilteredIndex = this.filteredOptions.indexOf(this.options[this.activeIndex]);
const action = getActionFromKey(key, this.open);
switch(action) {
case MenuActions.Next:
case MenuActions.Last:
case MenuActions.First:
case MenuActions.Previous:
event.preventDefault();
const nextFilteredIndex = getUpdatedIndex(activeFilteredIndex, max, action);
const nextRealIndex = this.options.indexOf(this.filteredOptions[nextFilteredIndex]);
return this.onOptionChange(nextRealIndex);
case MenuActions.CloseSelect:
event.preventDefault();
return this.updateOption(this.activeIndex);
case MenuActions.Close:
event.preventDefault();
return this.updateMenuState(false);
case MenuActions.Open:
return this.updateMenuState(true);
}
}
MultiselectButtons.prototype.onInputBlur = function() {
if (this.ignoreBlur) {
this.ignoreBlur = false;
return;
}
if (this.open) {
this.updateMenuState(false, false);
}
}
MultiselectButtons.prototype.onOptionChange = function(index) {
this.activeIndex = index;
this.inputEl.setAttribute('aria-activedescendant', `${this.idBase}-${index}`);
// update active style
const options = this.el.querySelectorAll('[role=option]');
[...options].forEach((optionEl) => {
optionEl.classList.remove('option-current');
});
options[index].classList.add('option-current');
if (this.open && isScrollable(this.listboxEl)) {
maintainScrollVisibility(options[index], this.listboxEl);
}
}
MultiselectButtons.prototype.onOptionClick = function(index) {
this.onOptionChange(index);
this.updateOption(index);
this.inputEl.focus();
}
MultiselectButtons.prototype.onOptionMouseDown = function() {
this.ignoreBlur = true;
}
MultiselectButtons.prototype.removeOption = function(index) {
const option = this.options[index];
// update aria-selected
const options = this.el.querySelectorAll('[role=option]');
options[index].setAttribute('aria-selected', 'false');
options[index].classList.remove('option-selected');
// remove button
const buttonEl = document.getElementById(`${this.idBase}-remove-${index}`);
this.selectedEl.removeChild(buttonEl.parentElement);
}
MultiselectButtons.prototype.selectOption = function(index) {
const selected = this.options[index];
this.activeIndex = index;
// update aria-selected
const options = this.el.querySelectorAll('[role=option]');
options[index].setAttribute('aria-selected', 'true');
options[index].classList.add('option-selected');
// add remove option button
const buttonEl = document.createElement('button');
const listItem = document.createElement('li');
buttonEl.className = 'remove-option';
buttonEl.type = 'button';
buttonEl.id = `${this.idBase}-remove-${index}`;
buttonEl.setAttribute('aria-describedby', `${this.idBase}-remove`);
buttonEl.addEventListener('click', () => { this.removeOption(index); });
buttonEl.innerHTML = selected + ' ';
listItem.appendChild(buttonEl);
this.selectedEl.appendChild(listItem);
}
MultiselectButtons.prototype.updateOption = function(index) {
const option = this.options[index];
const optionEls = this.el.querySelectorAll('[role=option]');
const optionEl = optionEls[index];
const isSelected = optionEl.getAttribute('aria-selected') === 'true';
if (isSelected) {
this.removeOption(index);
}
else {
this.selectOption(index);
}
this.inputEl.value = '';
this.filterOptions('');
}
MultiselectButtons.prototype.updateMenuState = function(open, callFocus = true) {
this.open = open;
this.comboEl.setAttribute('aria-expanded', `${open}`);
open ? this.el.classList.add('open') : this.el.classList.remove('open');
callFocus && this.inputEl.focus();
}
// init multiselect w/ top buttons
const multiButtonEl = document.querySelector('.js-multi-buttons');
const multiButtonComponent = new MultiselectButtons(multiButtonEl, options);
multiButtonComponent.init();
// init multiselect w/ inline buttons
const inlineButtonEl = document.querySelector('.js-inline-buttons');
const inlineButtonComponent = new MultiselectButtons(inlineButtonEl, options);
inlineButtonComponent.init();
Also see: Tab Triggers