Categories: CSSScriptWeb Design

Themeable Icon Picker In Vanilla JavaScript

A customizable, themeable icon picker that supports popular icon libraries like Font Awesome 6/7, Material Design Icons, and much more.

Table of Contents

Toggle

How to use it:

1. Load the main script icon-picker.min.js at the end of the document.

<script src="dist/icon-picker.min.js"></script>

2. Load a theme of your choice in the document. The library currently comes with 2 themes:

  • Default
  • Bootstrap 5
<!-- Default Theme -->
<link rel="stylesheet" href="dist/themes/default.min.css">
<!-- Bootstrap 5 Theme (Requires Bootstrap 5 Stylesheet) -->
<link rel="stylesheet" href="/path/to/cdn/bootstrap.min.css" />
<link rel="stylesheet" href="dist/themes/bootstrap-5.min.css">

3. Attach the icon picker to a trigger element like input or button.

<input type="text" id="icon-picker">
const iconPickerDemo = new IconPicker('input', {
      // options here
});

4. Set the theme of the icon picker.

const iconPickerDemo = new IconPicker('input', {
      theme: 'bootstrap-5',
});

5. Determine whether to close the icon picker after an icon has been selected. Default: true.

const iconPickerDemo = new IconPicker('input', {
      closeOnSelect: false,
});

6. Add more icon libraries to the icon picker. ‘FontAwesome Brands 5’ | ‘FontAwesome Solid 5’ | ‘FontAwesome Regular 5’ | ‘Material Design Icons’ | ‘Iconoir’, or a custom JSON path.

const iconPickerDemo = new IconPicker('input', {
      iconSource: [],
});
const iconPickerDemo = new IconPicker('input', { 
      iconSource: [
      {
        key: 'academicons',
        prefix: 'ai ai-',
        url: 'https://raw.githubusercontent.com/iconify/icon-sets/master/json/academicons.json'
      }], 
});

7. API methods.

// open the icon picker
iconPickerDemo.open();

// close the icon picker
iconPickerDemo.hide();

// clear the icon
iconPickerDemo.clear();

// check if the icon picker is opened
iconPickerDemo.isOpen();

// check if the icons are loaded
iconPickerDemo.iconsLoaded();

// destroy the instance
iconPickerDemo.destroy(deleteInstance);

8. Event handlers.

iconPickerDemo.on('select', (icon) => {
  // do something
});

iconPickerDemo.on('save', (icon) => {
  // do something
});

iconPickerDemo.on('clear', (icon) => {
  // do something
});

iconPickerDemo.on('show', instance => {
  // do something
});

iconPickerDemo.on('hide', instance => {
  // do something
});

Changelog:

v1.4.2 (11/04/2025)

  • Add FontAwesome 7

v1.4.1 (05/19/2025)

  • Add iconsLoaded method to check loading state of icons

v1.3.1 (08/09/2024)

  • Categories fix

v1.3.0 (02/21/2024)

  • feat: Add search by categories

v1.2.1 (10/03/2023)

  • Update

v1.2.0 (07/22/2023)

  • Add clear() method
  • Allow setting of ‘iconFormat’ in icon json so we can improve performance

v1.1.3 (04/01/2022)

  • Update dependencies and resolve deprecated webpack’s plugin
  • fix: Accessibility improvement

v1.1.2 (03/31/2022)

  • Updated dependencies

v1.1.0 (03/11/2022)

  • Add custom json path
  • Fix z-index problem

v1.0.0 (11/18/2021)

  • Add possibility to add more icons library
  • Set default value for input target

11/15/2021

  • fix: Add missing ‘!default’ and add variables

The post Themeable Icon Picker In Vanilla JavaScript appeared first on CSS Script.

rssfeeds-admin

Share
Published by
rssfeeds-admin

Recent Posts

Jodi’s Journal: The rest of the story behind Forward Sioux Falls

May 10, 2026 Imagine if the biggest, most influential businesses in this country came together…

20 minutes ago

Crimson Desert Adds Surprise Claw Machine Mini-Game and Lets Pet Dogs Attack Enemies as Part of Update 1.06.00

Crimson Desert developer Pearl Abyss has released this week’s update as promised, and it adds…

25 minutes ago

Nearly 50 Years Later, WKRP in Cincinnati Becomes a Real Radio Station

It took nearly 50 years. WKRP in Cincinnati is no longer just a TV sitcom.…

30 minutes ago

Record turnout, beautiful weather highlight Friday’s Chamber Golf Tournament at Big Creek

The Mountain Home Area Chamber of Commerce hosted its 2026 Four-Person Scramble Golf Tournament Friday…

38 minutes ago

Lead Hill man competes on Netflix reality show “Million Dollar Secret”

Growing up and spending all of his 44-years in Lead Hill and living on the…

39 minutes ago

MH Mayor Adams gives update on community center progress

Mountain Home Mayor Hillrey Adams says work is continuing at a rapid pace as the…

40 minutes ago

This website uses cookies.