Skip to content

Double Select Box

The Double Select Box component provides a user interface for moving items between two select boxes. It’s useful for scenarios where users need to select items from a list and move them to another list, such as assigning permissions, selecting features, or organizing items into categories.

This component has no additional dependencies beyond the core Metro UI library.

<div data-role="double-select-box">
<select>
<option value="1">Item 1</option>
<option value="2">Item 2</option>
<option value="3">Item 3</option>
<option value="4">Item 4</option>
</select>
<select>
<!-- Initially empty or with pre-selected items -->
</select>
</div>
<div data-role="double-select-box">
<select>
<option value="ie" data-template="<span class='mif-ie'></span> $1">IE</option>
<option value="chrome" data-template="<span class='mif-chrome'></span> $1">Chrome</option>
<option value="firefox" data-template="<span class='mif-firefox'></span> $1">Firefox</option>
</select>
<select>
<option value="safari" data-template="<span class='mif-safari'></span> $1">Safari</option>
<option value="opera" data-template="<span class='mif-opera'></span> $1">Opera</option>
</select>
</div>
ParameterTypeDefaultDescription
heightstring”auto”Height of the select boxes
multiSelectbooleanfalseAllows selecting multiple items at once
moveRightIconstring”›“Icon for the move right button
moveRightAllIconstring”»“Icon for the move all right button
moveLeftIconstring”‹“Icon for the move left button
moveLeftAllIconstring”«“Icon for the move all left button
clsBoxstring""Additional CSS class for the component container
clsMoveButtonstring""Additional CSS class for all move buttons
clsMoveRightButtonstring""Additional CSS class for the move right button
clsMoveRightAllButtonstring""Additional CSS class for the move all right button
clsMoveLeftButtonstring""Additional CSS class for the move left button
clsMoveLeftAllButtonstring""Additional CSS class for the move all left button
clsListLeftstring""Additional CSS class for the left list
clsListRightstring""Additional CSS class for the right list
// Global setup
Metro.doubleSelectBoxSetup({
multiSelect: true,
moveRightIcon: "→",
moveLeftIcon: "←"
});
// Component instance setup
const doubleSelectBox = Metro.getPlugin("#myDoubleSelectBox", "double-select-box");
  • destroy() - Removes the component from the DOM.
const doubleSelectBox = Metro.getPlugin("#myDoubleSelectBox", "double-select-box");
doubleSelectBox.destroy();
EventDescription
onDoubleSelectBoxCreateTriggered when the component is created
VariableDefault (Light)Dark ModeDescription
--double-select-border-radius4px4pxBorder radius of the select boxes
--double-select-border-colorvar(—border-color)var(—border-color)Border color of the select boxes
--double-select-item-background-active#e6e6e6#2c2d30Background color of active items
--double-select-item-color-active#191919#efefefText color of active items
--double-select-item-background-hover#e6e6e6#2c2d30Background color of items on hover
--double-select-item-color-hover#191919#efefefText color of items on hover
/* Custom styling for double select box */
.custom-double-select {
--double-select-border-radius: 8px;
--double-select-border-color: #2196F3;
--double-select-item-background-active: #e3f2fd;
--double-select-item-color-active: #0d47a1;
}
  • .double-select-box - The main container class for the component (automatically added)
  • Classes specified in the component parameters can be used to customize specific elements
  • Items can be moved between lists by:
  • Double-clicking on an item
  • Selecting an item and clicking the move buttons
  • Using the “move all” buttons to transfer all items at once
  • The component automatically creates the necessary UI elements (buttons, lists) based on the provided select elements
  • Items can include icons or custom HTML templates using data attributes
  • The component adapts to both light and dark themes
// Initialize a double select box programmatically
Metro.makePlugin('#myElement', 'double-select-box', {
multiSelect: true,
height: '300px',
moveRightIcon: '→',
moveLeftIcon: '←'
});
// Get a reference to an existing double select box
const doubleSelectBox = Metro.getPlugin('#myDoubleSelectBox', 'double-select-box');