Framework7 - Custom icons, colors and images



You can define custom icon, color or image on the smart select by using the data-option-icon, data-option-color and data-option-image attributes respectively.


The following example demonstrates the use of smart select in custom icons, colors and images in Framework7 −

<!DOCTYPE html>

      <meta name = "viewport" content = "width = device-width, initial-scale = 1, 
         maximum-scale = 1, minimum-scale = 1, user-scalable = no, minimal-ui" />
      <meta name = "apple-mobile-web-app-capable" content = "yes" />
      <meta name = "apple-mobile-web-app-status-bar-style" content = "black" />
      <title>Custom icons, colors and images</title>
      <link rel = "stylesheet" 
         href = "" />
      <link rel = "stylesheet" 
         href = "" />

      <div class = "views">
         <div class = "view view-main">
            <div class = "navbar">
               <div class = "navbar-inner">
                  <div class = "left"> </div>
                  <div class = "center sliding">Smart Select Custom Icons, Colors and Images</div>
                  <div class = "right"> </div>
            <div class = "pages navbar-through">
               <div data-page = "home" class = "page">
                  <div class = "page-content">
                     <div class = "list-block">
                              <a href = "#" class = "item-link smart-select">
                                 <select name = "countries">
                                    <option value = "India" selected data-option-image = "images/ind.gif">India</option>
                                    <option value = "Newz = Zealnad" data-option-image = "images/arg.gif">Argentina</option>
                                    <option value = "Srilanka" data-option-color = "red" data-option-image = "images/bgm.gif">Belgium</option>
                                 <div class = "item-content">
                                    <div class = "item-inner">
                                       <div class = "item-title">Countries</div>
      <script type = "text/javascript" 
         src = ""></script>
         // here initialize the app
         var myApp = new Framework7 ({

         // If your using custom DOM library, then save it to $$ variable
         var $$ = Dom7;

         // Add the view
         var mainView = myApp.addView('.view-main', {
            // enable the dynamic navbar for this view
            dynamicNavbar: true



Let us carry out the following steps to see how the above given code works −

  • Save the above given HTML code as smart_select_icons_colors_images.html file in your server root folder.

  • Open this HTML file as http://localhost/smart_select_icons_colors_images.html and the output is displayed as shown below.

  • The output shows the use of data-option-icon, data-option-color and data-option-image to define the custom icon, color or image for smart select.

  • When you click on the option named as countries, a list of different countries is displayed with icon, color or image which allows you to select any one option.