SEO-friendly Tree View Plugin For Bootstrap 4 - bstree

SEO-friendly Tree View Plugin For Bootstrap 4 - bstree
File Size: 135 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT

bstree is a simple-to-use jQuery/Bootstrap 4 plugin used to present hierarchical data in a semantic, collapsible tree view with checkboxes.


  • SEO friendly. The plugin renders a tree view from nested HTML lists.
  • Supports Three State Checkbox: checked, unchecked, or indeterminate.
  • Font Awesome icons.
  • Lots of configuration options.

How to use it:

1. Load the needed jQuery library, Bootstrap 4 framework, and Font Awesome iconic font in the html document.

<link rel="stylesheet" href="" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" href="">
<script src="" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

2. Download and import the jQuery bstree plugin's files.

<link rel="stylesheet" href="bstree.css">
<script src="jquery.bstree.js"></script>

3. Insert your hierarchical data in nested HTML lists as follows:

  • data-id: node ID
  • date-level: node level
<div id="mytree" class="bstree">
    <li data-id="root" data-level="0"><span>Racine</span>
        <li data-id="ACL" data-level="1"><span>Alsace - Champagne-Ardenne - Lorraine</span>
            <li data-id="ALS" data-level="2"><span>Alsace</span>
                <li data-id="ALS01" data-level="3"><span>Colmar</span></li>
                <li data-id="ALS02" data-level="3"><span>Mulhouse</span></li>
                <li data-id="ALS03" data-level="3"><span>Darmstadt</span></li>
            <li data-id="CHA" data-level="2"><span>Champagne-Ardenne</span>
                <li data-id="CHA01" data-level="3"><span>Bazeilles</span></li>
                <li data-id="CHA02" data-level="3"><span>Châlons-en-Champagne</span></li>
                <li data-id="CHA03" data-level="3"><span>Charleville-Mézières</span></li>
            <li data-id="LOR" data-level="2"><span>Lorraine</span>
                <li data-id="LOR01" data-level="3"><span>Cosnes-et-Romain</span></li>
                <li data-id="LOR02" data-level="3"><span>Épinal</span></li>
                <li data-id="LOR03" data-level="3"><span>Forbach</span></li>

4. Call the function to render a basic tree view on the page.

$('document').ready(function () {

5. Add checkboxes to the nodes.

<input id="bstree-data" type="hidden" name="bstree-data" data-ancestors="ALS:IDF">
<div id="mytree" class="bstree">
$('document').ready(function () {
  $hiddenInput = $('#bstree-data')
    dataSource: $hiddenInput,
    initValues: $'ancestors'),
    onDataPush: function (values) {
      var def = '<strong class="pull-left">Values:&nbsp;</strong>'
      for (var i in values) {
        def += '<span class="pull-left">' + values[i] + '&nbsp;</span>'
    updateNodeTitle: function (node, title) {
      return '[' + node.attr('data-id') + '] ' + title + ' (' + node.attr('data-level') + ')'

6. All default configuration options to customize the tree view.

  DEBUG: false,
  dataSource: '',                                      // the source control id
  initValues: '',
  dataSeparator: ':',                                     // the separator used for the exploded data
  chevronOpened: '<i class="fa fa-toggle-down fa-lg"></i>',    // the icon used for an opened node
  chevronClosed: '<i class="fa fa-toggle-right fa-lg"></i>',   // the icon used for a closed node
  isExpanded: false,                                 // sets if nodes are initially expanded
  nodeClass: pluginName + '-node',                      //  generic node class
  compositeClass: pluginName + '-composite',                 //  composite node class
  leafClass: pluginName + '-leaf',                      //  leaf node class
  childrenClass: pluginName + '-children',                  //  node children class
  innerContainerClass: pluginName + '-inner-container',
  chevronClass: pluginName + '-chevron',                   //  chevron icon class
  labelClass: pluginName + '-label',                     //  label class
  labelContainerClass: pluginName + '-label-container',
  iconClass: pluginName + '-icon',                      //  label icon class
  expandedClass: pluginName + '-expanded',                  //  opened node class
  closedClass: pluginName + '-closed',                    //  closed node class
  checkboxClass: pluginName + '-checkbox',                  //  checkbox class
  incompleteClass: pluginName + '-incomplete',                //  incomplete node class
  vLineClass: pluginName + '-vline',
  dataClass: pluginName + '-data',
  openTitle: 'Open',
  closeTitle: 'Close',
  checkboxTitle: 'Do action',
  updateNodeTitle: null,
  onDataPush: null

This awesome jQuery plugin is developed by glimberger. For more Advanced Usages, please check the demo page or visit the official website.