Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <!-- Simple template for the ListView instantiation  -->
<div class="smallListIconTextTemplate" 
     style="display: none">
    <div class="smallListIconTextItem">
        <span class="date-picker">
          <img src="#" 
             class="smallListIconTextItem-Image date-picker" 
             data-win-bind="src: picture"
        <div class="smallListIconTextItem-Detail">
            <h4 class="win-h4" data-win-bind="textContent: title"></h4>
            <h6 class="win-h6" data-win-bind="textContent: text"></h6>
            <h6 class="win-h6 counter" data-win-bind="innerText: counter"></h6>

<div class="listLayoutTopHeaderTemplate" data-win-control="WinJS.Binding.Template">
    <div class="listLayoutTopHeaderTemplateRoot">
        <div data-win-bind="innerHTML: title"></div>

<!-- Elements used for header and footer elements for ListView -->
<div class="headerFooterPlaceholder">
    <div class="header">
        <span style="display: inline-block;">
          <h2 class="win-h2">Ordered ListView with Editing Items</h2>
              <span>Total Items: </span>
              <span data-win-bind="textContent: data.length"></span>
      <span style="display: inline-block; float: right;">
        <button class="win-button" data-win-bind="onclick: eh.toggleStripes">
          Toggle Odd/Even
        <button id="removeSelected" class="win-button" data-win-bind="onclick: eh.removeSelected">
    <div class="footer">
          <button class="win-button" 
                  data-win-bind="onclick: eh.backToTop">
            Back to Top
        <div class="status">
            <div>Loading more items </div>
            <progress class="win-progress-bar progress hide"></progress>

<div id="listView"
     class="listView stripes win-selectionstylefilled "
            itemTemplate: select('.smallListIconTextTemplate'),
            header: select('.header'),
            footer: select('.footer'),
            layout: { type: WinJS.UI.ListLayout, groupHeaderPosition: 'top'},
            groupHeaderTemplate: select('.listLayoutTopHeaderTemplate'),                        
            selectionMode: 'multi',
            tapBehavior: WinJS.UI.TapBehavior.toggleSelect
              /* Template for the items in the ListViews in this sample */       
    width: 100%;
    height: 70px;
    padding: 5px;
    overflow: hidden;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;

    .smallListIconTextItem img.smallListIconTextItem-Image 
        width: 64px;
        height: 64px;
        margin: 5px;

    .smallListIconTextItem .smallListIconTextItem-Detail
        margin: 5px;

   .listLayoutTopHeaderTemplateRoot, .gridLayoutLeftHeaderTemplateRoot {
        font-size: larger;
        margin-left: 16px;
/* CSS applied to the ListViews in this sample */
    height: 100%;

.headerFooterPlaceholder {
    display: none;

.listView .header,
.listView .footer {
    height: 80px;
    padding: 10px;
    background-color: #333;

.listView .footer .progress.hide {
    display: none;
} {
  display: none;
} {
  font-family: FontAwesome;
  content: "\f03e";
  color: grey;
  font-size: 64px;
  display: inline-block;
  margin-top: 0em;
  margin-bottom: 0em;
  margin-right: 5px;

/* Override the background color for even/odd win-containers */
.listView.stripes {
    background-color: #212;

.listView.stripes {
    background-color: #424;

.counter {
    font-size: 8pt;
    position: absolute;
    top: 0px;
    right: 5px;
    width: 20px;
    height: 20px;
    text-align: left;

               var itemArray = [
    { title: "Banana Blast", text: "Low-fat frozen yogurt", picture: "/images/fruits/60Banana.png" }

// For Example of loading
var itemArray2 = [
    { title: "Banana Blast Two", text: "Low-fat frozen yogurt", picture: "/images/fruits/60Banana.png" }, 
    { title: "Marvelous Mint", text: "Gelato", picture: "/images/fruits/60Mint.png" },
    { title: "Succulent Strawberry", text: "Sorbet", picture: "/images/fruits/60Strawberry.png" },
    { title: "Lavish Lemon Ice", text: "Sorbet", picture: "/images/fruits/60Lemon.png" },
    { title: "Creamy Orange", text: "Sorbet", picture: "/images/fruits/60Orange.png" },
    { title: "Very Vanilla", text: "Ice Cream", picture: "/images/fruits/60Vanilla.png" },
    { title: "Lavish Lemon Ice Two", text: "Sorbet", picture: "/images/fruits/60Lemon.png" }

function generateItems() {
  var tIndex = 0;
    item.counter = tIndex++;
  return itemArray;

var items = generateItems();
var data = new WinJS.Binding.List(items);

var groupedData = data.createGrouped(function (item) {
    return item.title.toUpperCase().charAt(0);
}, function (item) {
    return {
        title: item.title.toUpperCase().charAt(0)
}, function (left, right) {
    return left.charCodeAt(0) - right.charCodeAt(0);

WinJS.Namespace.define("Sample.ListView", {
    generate: generateItems,
    data: groupedData,
    eh: {
        footerVisibility: WinJS.UI.eventHandler(function (ev) {
            var visible = ev.detail.visible;
            if (visible) {
                WinJS.Utilities.removeClass(Sample.ListView.progress, "hide");

                // Simulate XHR by just setting a timeout and updating the observable binding list     
                WinJS.Promise.timeout(100).then(function () {
                  var items = itemArray2;
                  items.forEach(function (item) {
            } else {
                WinJS.Utilities.addClass(Sample.ListView.progress, "hide");
        toggleStripes: WinJS.UI.eventHandler(function (ev) {   
            WinJS.Utilities.toggleClass(Sample.ListView.listView, "stripes");         
        backToTop: WinJS.UI.eventHandler(function (ev) {
            Sample.ListView.listView.winControl.scrollPosition = 0;
        removeSelected: WinJS.UI.eventHandler(function (ev) {
            //Sample.ListView.listView.winControl.scrollPosition = 0;

// Remove the selected tile
function removeSelected() {
  // Get the control
  //var list2 = document.getElementById("listView").winControl;
  var list2 = Sample.ListView.listView.winControl;
  if (list2.selection.count() > 0) {
    list2.selection.getItems().done(function (items) {

      //Sort the selection to ensure its in index order
      items.sort(function CompareForSort(item1, item2) {
        var first = item1.index, second = item2.index;
        if (first === second) {
          return 0;
        } else if (first < second) {
          return -1;
        else {
          return 1;

      //Work backwards as the removal will affect the indices of subsequent items
      for (var j = items.length - 1; j >= 0; j--) {
        // To remove the items, call splice on the list, passing in a count and no replacements
        data.splice(items[j].index, 1);

// Cache ListView and Header elements
Sample.ListView.listView = document.querySelector(".listView");
Sample.ListView.header = document.querySelector(".header");
Sample.ListView.progress = document.querySelector(".footer .progress");
Sample.ListView.status = document.querySelector(".footer .status");

// Data bind header element and split pane element
WinJS.Binding.processAll(Sample.ListView.header, Sample.ListView).then(function () {
    return WinJS.Binding.processAll(Sample.ListView.splitPane, Sample.ListView);
}).then(function () {
    // Process UI to initialize WinJS controls 
    return WinJS.UI.processAll();

var msToTime = function(duration) {
  var milliseconds = parseInt((duration % 1000)/100);
  var seconds = parseInt((duration / 1000) % 60);
  var minutes = parseInt((duration / (1000*60)) % 60);
  var hours = parseInt((duration / (1000*60*60)) % 24);

  hours = (hours < 10) ? "0" + hours : hours;
  minutes = (minutes < 10) ? "0" + minutes : minutes;
  seconds = (seconds < 10) ? "0" + seconds : seconds;

  return hours + ":" + minutes + ":" + seconds + "." + milliseconds;
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.