Framework7 - Custom icons, colors and images



Description

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.

Example

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

<!DOCTYPE html>
<html>

   <head>
      <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 = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.ios.min.css" />
      <link rel = "stylesheet" 
         href = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.ios.colors.min.css" />
   </head>

   <body>
      <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>
            </div>
            
            <div class = "pages navbar-through">
               <div data-page = "home" class = "page">
                  <div class = "page-content">
                     <div class = "list-block">
                        <ul>
                           <li>
                              <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>
                                 </select>
                                 
                                 <div class = "item-content">
                                    <div class = "item-inner">
                                       <div class = "item-title">Countries</div>
                                    </div>
                                 </div>
                              </a>
                           </li>
                        </ul>
                     </div>
                  </div>
                  
               </div>
            </div>
         </div>
      </div>
      
      <script type = "text/javascript" 
         src = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/js/framework7.min.js"></script>
         
      <script>
         // here initialize the app
         var myApp = new Framework7 ({
            animateNavBackIcon:true
         });

         // 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
         });
      </script>
   </body>

</html>

Output

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.

framework7_forms.htm
Advertisements