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


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
  <title>Clickable sidebar demo</title>
  <link rel="stylesheet" href="">
  <script src=""></script>

  <div class="panel-container">
    <div class="panel-side">
      <h2>Selected Counties</h2>
      <ul id="list_counties">
    <div id="viewDiv"></div>


    #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    .panel-container {
      position: relative;
      width: 100%;
      height: 100%;

    .panel-side {
      padding: 2px;
      box-sizing: border-box;
      width: 300px;
      height: 100%;
      position: absolute;
      top: 0;
      right: 0;
      color: #fff;
      background-color: rgba(0, 0, 0, 0.6);
      overflow: auto;
      z-index: 60;

    .panel-side h2 {
      padding: 0 20px;
      margin: 20px 0;

    .panel-side ul {
      list-style: none;
      margin: 0;
      padding: 0;

    .panel-side li {
      padding: 5px 20px;

    .panel-result {
      cursor: pointer;
      margin: 2px 0;
      background-color: rgba(0, 0, 0, 0.3);

    .panel-result:focus {
      color: orange;
      background-color: rgba(0, 0, 0, 0.75);


], function(Map, MapView, FeatureLayer, Graphic, SimpleFillSymbol, GraphicsLayer, Query) {

  var whereClause = "NO_FARMS87 > 500";

  var map = new Map({
    basemap: "dark-gray"

  var view = new MapView({
    container: "viewDiv",
    map: map,
    zoom: 7,
    center: [-78, 41]

  var listNode = document.getElementById("list_counties");
  var popupInfo = {
    title: "{NAME} County",
    content: "<b> Farms: {NO_FARMS87} </b>"
  var counties = new FeatureLayer({
    portalItem: {
      id: "63606938ae2245b1b293c60cfb9c0d30"
    popupTemplate: popupInfo

  var resultsLayer = new GraphicsLayer();
  map.addMany([counties, resultsLayer]);

  var farmQuery = new Query({
    where: whereClause,
    returnGeometry: true,
    outFields: ["NAME", "NO_FARMS87"]
  counties.when(function() {
    return counties.queryFeatures(farmQuery);

  var graphics = [];
  function displayResults(results) {
    var fragment = document.createDocumentFragment();
    results.features.forEach(function(county, index) {
      county.symbol = new SimpleFillSymbol({
        color: "yellow"
      var attributes = county.attributes;
      var name = attributes.NAME + " (" +
        attributes.NO_FARMS87 + ")";
      var li = document.createElement("li");
      li.tabIndex = 0;
      li.setAttribute("data-result-id", index);
      li.textContent = name;


    listNode.innerHTML = "";

  listNode.addEventListener("click", onListClickHandler);

  function onListClickHandler(event) {
    var target =;
    var resultId = target.getAttribute("data-result-id");

    var result = resultId && graphics && graphics[parseInt(resultId,

    if (result) {{
        features: [result],
        location: result.geometry.centroid