npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@elrayes/dual-listbox

v0.3.1

Published

A zero-dependency (vanilla JS) dual list box with grouping, search, select-all, theming (Bootstrap/Tailwind), and TypeScript types.

Readme

@elrayes/dual-listbox

A zero-dependency (vanilla JS) dual-list box with grouping, search, select-all, and theming (Bootstrap 5.2 default, Tailwind optional) with TypeScript types.

Installation

npm install @elrayes/dual-listbox

Usage (ES Modules)

import { DualListBox, useTheme, tailwindTheme} from '@elrayes/dual-listbox';
import { tailwindTheme } from '@elrayes/dual-listbox';
useTheme(tailwindTheme); // sets global default for all new instances 
DualListBox.setTheme(tailwindTheme); // alias for useTheme()
import '@elrayes/dual-listbox/styles/core.css';
import '@elrayes/dual-listbox/themes/bootstrap.css'; // or tailwind.css

const items = [
  { item: 'Apple', value: 1, group: 'Fruits' },
  { item: 'Tomato', value: 2, group: 'Vegetables' },
];

const dlb = new DualListBox('#dual-listbox-container', {
  dataArray: items,
  selectedItems: [],
  onSubmit: (selected, unselected, all, selectedArray) => {
    console.log(selectedArray);
  },
});

// New methods (no duplicates)
const selectedItems = dlb.getSelectedItems();
const unselectedItems = dlb.getUnselectedItems();
const allItems = dlb.getAllItems();

Usage (CommonJS)

const { DualListBox } = require('@elrayes/dual-listbox');
require('@elrayes/dual-listbox/styles/core.css');
require('@elrayes/dual-listbox/themes/bootstrap.css');

const dlb = new DualListBox('#dual-listbox-container', { /* options */ });

Options (TypeScript)

export interface DualListBoxOptions {
  itemName?: string; // default "item"
  groupName?: string; // default "group"
  valueName?: string; // default "value"
  inputName?: string; // form input name for hidden fields
  tabNameText?: string;
  rightTabNameText?: string;
  searchPlaceholderText?: string;
  includeButtonText?: string;
  excludeButtonText?: string;
  dataArray?: any[];
  selectedItems?: any[];
  hideEmptyGroups?: boolean;
  submitForm?: boolean;
  onSubmit?: (selected, unselected, allItems, selectedArray) => void | null;
  theme?: Partial<DualListBoxTheme>;
}

Theming

  • Built-in theme maps classes to your CSS framework.
  • Presets: Bootstrap 5.2 (defaultTheme) and Tailwind (tailwindTheme).
  • You can set a global default for all new instances using useTheme:
import { DualListBox, useTheme } from '@elrayes/dual-listbox';
import { tailwindTheme } from '@elrayes/dual-listbox/dist/themePresets';

useTheme(tailwindTheme); // applies to all new DualListBox instances

new DualListBox('#el'); // uses the global Tailwind theme
  • Or provide a custom theme per instance (an instance option has priority over global):
new DualListBox('#el', {
  theme: {
    // override any class strings
    btn: 'my-btn my-btn--primary',
  }
});

Note: For backward compatibility, DualListBox.setTheme(tailwindTheme) is still available and is an alias to useTheme(tailwindTheme).

Alternatively, rely on CSS variables and write a stylesheet that targets .dual-listbox.

Laravel + Vite Integration

  1. Place the container in your Blade:
<div id="dual-listbox-container"></div>
  1. Import and initialize in your app JS that Vite builds.

  2. Include core.css and choose a theme stylesheet.

API

  • new DualListBox(element, options)
  • getSelectedValues(): Promise<(string|number)[]> (legacy values API)
  • Getters: selected, unselected, allItems, selectedArray
  • New methods (return item objects without duplicates):
    • getSelectedItems()
    • getUnselectedItems()
    • getAllItems()

License

MIT