Drupal is a registered trademark of Dries Buytaert
Menu Per Role 8.x-1.9 Minor update available for module menu_per_role (8.x-1.9). AI (Artificial Intelligence) 1.5.0-alpha1 First alpha version released for module ai (1.5.0-alpha1). Easy Encryption 1.0.4 Minor update available for module easy_encryption (1.0.4). Soccerbet 1.1.15 Minor update available for module soccerbet (1.1.15). United Nations Maps & Geoservices 3.0.8 Minor update available for module unep_maps (3.0.8). Burndown 1.0.71 Minor update available for module burndown (1.0.71). Bible 3.4.1 Minor update available for module bible (3.4.1). Bible 3.4.0 Minor update available for module bible (3.4.0). Menu Per Role 2.0.0 Module menu_per_role updated after 7 months of inactivity (2.0.0). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module allows developers to create custom select elements within Drupal's Form API that display icons next to each option. It uses jQuery UI to enhance the standard select functionality, enabling visual representation for choices.

This module provides a Form API select element with icons using jQuery UI.

This module is for developers only. It does not provide any user functionality.

With Select icons you can easily create select element with icons of your choice
using nothing but drupal Forms API and some CSS:

$form['fancy_select'] = [
  '#type' => 'select_icons',
  '#title' => $this->t('Color'),
  '#options' => [
    'r' => $this->t('Red'),
    'g' => $this->t('Green'),
    'b' => $this->t('Blue'),
  ],
  // This is where magic happens:
  // CSS classes from 'data-class' attribute are used in JavaScript
  // when building jQuery UI selectmenu widget.
  '#options_attributes' => [
    'r' => new Attribute(['data-class' => ['color', 'red']]),
    'g' => new Attribute(['data-class' => ['color', 'green']]),
    'b' => new Attribute(['data-class' => ['color', 'blue']]),
  ],
  // Don't forget to add proper CSS that will provide icons.
  // It is recommended to use sprite sheets for better performance.
  '#attached' => [ 'library' => ['my/colors'] ],
];

Requirements

Similar projects and how they are different

  • Select2 Boxes - Select2 Boxes integrates with Select2 library and provides field widget plugins while Select Icons integrates with jQuery UI and is for developer.

Maintainers

Previous maintainers

Activity

Total releases
2
First release
Jul 2026
Latest release
19 hours ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Active

Releases

Version Type Release date
2.1.0 Stable Jul 19, 2026
2.x-dev Dev Jul 19, 2026