Framework7 => Chis/Tags – Add From Javascript Array

User Management System
Learn Kotlin, Retrofit, MVVM and MySQL using this all-in-one app. It is designed to be beginner friendly.

Chips are a very popular way of showing tags in websites or contacts in mobile devices.Chips are sometimes called tags. Framework7 provides easy to use and customizable tags/chips that we can use in our app.

Chips can contain text, media/images, and button. The button can be used to delete the chip. So today we see how to make a chip with text, media and delete button. The delete button can be used to dismiss the chip. We will generate chips programmatically via Javascript from an array.

Questions this Project answers.

  • Framework7 dismissable chips.
  • Framework7 deletable tags.
  • Getting started with framework7.
  • Framework7 chips/tags tutorial.

Libraries Used

These are the third parties used in this project.

  • Here's the screenshot of the project.

Framework7 ToolBar Tabs

  • Project Structure

Project Structure

Tools used

Language: Javascript,HTML,CSS

Framework: Framework7

IDE: PHPStorm.

Topic: Framework7 dismissable chips,Framework7 tags.

Source Code

Lets have a look at the source code.


  • Our index.html file.
  • We reference framework7 material css in the header.
  • We also reference our javascript scripts at the base of the body.
<!DOCTYPE html>
    <meta charset="utf-8">
    <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">


    <!-- REFERENCE CSS-->
    <link rel="stylesheet" href="assets/css/framework7.material.min.css">
    <link rel="stylesheet" href="assets/css/framework7.material.colors.min.css">
    <link rel="stylesheet" href="assets/css/my-app.css">


    <!-- VIEWS-->
    <div class="views">

      <!-- Your main view, should have "view-main" class-->
      <div class="view view-main">

        <!-- Top Navbar-->
        <div class="navbar">
          <div class="navbar-inner">

            <!-- We have home navbar without left link-->
            <div class="center sliding"></div>
            <div class="right">
              <!-- Right link contains only icon - additional "icon-only" class--><a href="#" class="link icon-only"> <i class="icon icon-bars"></i></a>

        <!-- Pages, because we need fixed-through navbar and toolbar, it has additional appropriate classes-->
        <div class="pages navbar-through toolbar-through">

          <!-- Page, data-page contains page name-->
          <div data-page="index" class="page">

            <!-- Scrollable page content-->
            <div class="page-content">
              <div class="content-block-title">Deletable Chips / Tags</div>
              <div class="content-block">
                <div id="displaySectionID">

              <div class="content-block">
                <div class="row">
                  <div class="col-50"><a href="#" id="setChipsBtn" class="button button-raised button-fill color-cyan">Set Chips</a></div>

        <!-- Bottom Toolbar-->
        <div class="toolbar">
          <div class="toolbar-inner"><a href="#" class="link">Home</a><a href="#" class="link">About Us</a></div>

    <script type="text/javascript" src="assets/js/framework7.min.js"></script>
    <script type="text/javascript" src="assets/js/main.js"></script>


  • Main class.
  • Initialize Framework7 and Dom7 here.
  • Define data source.
  • Create chips programmatically based on the data we have in the data source.
var mainClass=function()
     -Initialize your app
     -Export selectors engine
    var myApp = new Framework7();
    var $$ = Dom7;
    var galaxies=["StarBust","Cartwheel","MilkyWay","Sombrero","Whirlpool","IC1011"];

     - Initialize app
        $$('#setChipsBtn').on('click', function () {
            m=new mainClass();
            for(var i=0;i<galaxies.length;i++)
     - Create and return a chip
        var chip=document.createElement('div');

        //chip label
        var chipLabel=document.createElement('div');

        //chip media
        var chipMedia=document.createElement('div');
        chipMedia.className='chip-media bg-teal';

        //chip delete btn
        var deleteBtn=document.createElement('a');


        //delete chip
        deleteBtn.onclick=function (e) {
            myApp.confirm('Do you want to delete '+galaxyName, function () {

        return chip;

m=new mainClass();

Video Tutorial

Below is the video version of this tutorial.


  • Download the Project below.


How to Download and Run.

  1. Download the project above.
  2. You'll get a zipped file,extract it.
  3. You'll have three files : html,css and javascript.
  4. Place them in a folder and run the index.html file.That's it.


  • Visit our channel for more examples like these.
  • Lets share tips and ideas in our Facebook Page.


Learn Android Retrofit using our course

Android MySQL Retrofit2 Multipart CRUD,Search,Pagination rating

When I was a 2nd year Software Engineering student, I buillt a now defunct online tool called Camposha(from Campus Share) using my then favorite language C#(ASP.NET) to compete OLX in my country(Kenya). The idea was to target campus students in Kenya. I got a few hundred signups but competing OLX proved too daunting. I decided to focus on my studies, learning other languages like Java,Python,Kotlin etc while meanwhile publishing tutorials at my YouTube Channel ProgrammingWizards TV which led to this site( Say hello or post me a suggestion: . Follow me below; Github , and on my channel: ProgrammingWizards TV

We will be happy to hear your thoughts

Leave a reply

+ twenty six = 34

Reset Password
Compare items
  • Total (0)
Shopping cart