title: How to make a Mapbox GL JS popup open as a side panel
body: <p>I'm trying to get a Mapbox GL JS popup open as a side panel instead of opening in a position relative to the marker.</p>
  
  <p>I worked on something:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.label {
    color: black;
    font-weight: bold;
  }
  
  .popup-header {
    background: blue;
    color: white;
    height: 80px;
    width: 370px;
    margin: -10px;
    border-radius: 5px 5px 0px 0px;
    position: fixed;
    z-index: 900;
  }
  
  .popup-header h2 {
    padding: 10px;
  }
  
  .address{
    font-weight: bold;
    color: black;
  }
  
  p {
    color: gray;
  }
  
  h3 {
  
  }
  
  h3:before {
    content: "\f105";
    font-family: "Font Awesome 5 Free";
    color: blue;
    padding-right: 3px;
  }
  
  .hidden {
    visibility: hidden;
  }
  
  /* Pop-up style */
  .mapboxgl-popup-close-button {
    display: block;
    color: white;
    z-index: 1000;
  }
  
  .mapboxgl-popup-content {
    font: 400 15px/22px 'Roboto', 'Helvetica Neue', Sans-serif;
    padding: 0;
    width: 350px;
    overflow-y: auto;
    height: 400px;
  }
  
  .popup-content-position {
    position: relative;
    top: 70px;
  }
  
  .mapboxgl-popup-content-wrapper {
    padding: 1%;
  }
  
  .mapboxgl-popup-tip {
   display: none;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta charset='utf-8' /&gt;
      &lt;title&gt;Carte du ski hors piste dans l'Est de l'Amérique du Nord&lt;/title&gt;
      &lt;meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /&gt;
   &lt;!-- JavaScript --&gt;   
      &lt;script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.51.0/mapbox-gl.js'&gt;&lt;/script&gt;
   &lt;!-- CSS --&gt;   
      &lt;link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.51.0/mapbox-gl.css' rel='stylesheet' /&gt;
  &lt;!--Icons--&gt;   
      &lt;link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css" integrity="sha384-gfdkjb5BdAXd+lj+gudLWI+BXq4IuLW5IT+brZEZsLFm++aCMlF1V92rMkPaX4PP" crossorigin="anonymous"&gt;
      &lt;style&gt;
        body {
          margin: 0;
          padding: 0;
        }
  
        #map {
          position: absolute;
          top: 0;
          bottom: 0;
          width: 100%;
          z-index: 1000;
        }
      &lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div id='map'&gt;&lt;/div&gt;
      &lt;script&gt;
      mapboxgl.accessToken = 'pk.eyJ1IjoibG91aXNjaGF1c2UiLCJhIjoiY2pud2hnaTViMDM2ZzNwbjR1M2UydWIzZCJ9.wELVs_IfGRvQTGvHsdTheA'; // replace this with your access token
      var map = new mapboxgl.Map({
        container: 'map',
        style: 'mapbox://styles/louischause/cjoofi76c0wzh2rmtwsmuovx3', // replace this with your style URL
        center: [-68.560022, 45.972663],
        zoom: 5.59
      });
  map.on('click', function(e) {
    var features = map.queryRenderedFeatures(e.point, {
      layers: ['mapow-location'] // replace this with the name of the layer
    });
  
    if (!features.length) {
      return;
    }
  
    var feature = features[0];
  
    var popup = new mapboxgl.Popup({ offset: [0,0] })
      .setLngLat(feature.geometry.coordinates)
      .setHTML('&lt;div class="popup-header"&gt;&lt;h2&gt;' + feature.properties.name + '&lt;/h2&gt;&lt;/div&gt;&lt;div class="popup-content-position"&gt;&lt;p class="address"&gt;' + feature.properties.address + '&lt;/p&gt;&lt;h3&gt;Météo actuelle&lt;/h3&gt;&lt;p&gt;' + feature.properties.test + '&lt;/p&gt;&lt;h3&gt;Prévisions météo&lt;/h3&gt;&lt;p&gt;' + feature.properties.test + '&lt;/p&gt;&lt;h3&gt;Détails techniques&lt;/h3&gt;&lt;p&gt;&lt;span class="label"&gt;Dénivelé&lt;/span&gt;&lt;br&gt;' + feature.properties.denivele + '&lt;/p&gt;&lt;p&gt;&lt;span class="label"&gt;Classification&lt;/span&gt;&lt;br&gt;' + feature.properties.classification + '&lt;/p&gt;&lt;p&gt;&lt;span class="label"&gt;Approche&lt;/span&gt;&lt;br&gt;' + feature.properties.approche + '&lt;/p&gt;&lt;p&gt;&lt;span class="label"&gt;Type de station&lt;/span&gt;&lt;br&gt;' + feature.properties.type_station + '&lt;/p&gt;&lt;p&gt;&lt;span class="label"&gt;Types de remontée offertes&lt;/span&gt;&lt;br&gt;' + feature.properties.type_remontees + '&lt;/p&gt;&lt;h3&gt;Détails concernant le prix&lt;/h3&gt;&lt;p&gt;' + feature.properties.price + '&lt;/p&gt;&lt;p&gt;' + feature.properties.price_comment + '&lt;/p&gt;&lt;h3&gt;Informations utiles&lt;/h3&gt;&lt;p&gt;&lt;span class="label"&gt;Site web&lt;/span&gt;&lt;br&gt;' + feature.properties.website + '&lt;/p&gt;&lt;p&gt;&lt;span class="label"&gt;Courriel&lt;/span&gt;&lt;br&gt;' + feature.properties.mail + '&lt;/p&gt;&lt;p&gt;&lt;span class="label"&gt;Téléphone&lt;/span&gt;&lt;br&gt;' + feature.properties.phone + '&lt;/p&gt;&lt;h3&gt;Photos et vidéos récentes&lt;/h3&gt;&lt;p&gt;' + feature.properties.instagram_media_embed + '&lt;/p&gt;&lt;/div&gt;')
      .setLngLat(feature.geometry.coordinates)
      .addTo(map);
  });
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>If you click on a red marker you'll see that popup is opening right on the marker.</p>
  
  <p>How can I edit my js code so it opens as a side panel (like when we click on a marker on google maps)</p>
  
  <p>Here is the UI I developed that I want to trigger instead of the pop-up. codepen.io/louischausse/pen/oVwgYN </p>