Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

HTML

              
                <base href="https://raw-dot-custom-elements.appspot.com/Dabolus/cookie-consent/2.0.2/cookie-consent/">

<script src="../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="cookie-consent.html">

<style>
  cookie-consent {
    --cookie-consent-reject-text-color: pink;
    --cookie-consent-policy-link-color: green;
  }
</style>

<h3>Fully working example with rejection</h3>
<p>In this example, your real position will be mocked so that you can see the toast even if you are outside of the EU.</p>
<p>We are also using the <code>use-session-storage</code> option so that you can just close the page and re-open it to test the consent again.</p>
<dom-bind>
  <template>    
    <cookie-consent id="consent" cookies-status="{{state}}" policy-link="#" rejectable seconds-before-appearing="1" geo-ip-url="./demo/eu.json" use-session-storage></cookie-consent>
    <div>Cookie consent state: [[state]]</div>
    <div id="afterUserResponds">Waiting for user response...</div>
  </template>
</dom-bind>

<script>
  var afterUserResponds = document.querySelector("#afterUserResponds");

  var cookieConsent = document.querySelector("#consent");

  cookieConsent.addEventListener("cookies-status-changed", function(e) {
    switch (e.detail.value) {
      case "accepted":
        afterUserResponds.innerHTML =
          "The user has accepted, now I can do what I need to!";
        break;
      case "rejected":
        afterUserResponds.innerHTML = "The user has rejected, no cookies :(";
        break;
    }
</script>
























<div class="vd-container"><div class="vd"><a target="_blank" href="https://vaadin.com/directory/component/Daboluscookie-consent">Check out cookie-consent on Vaadin Directory</a></div></div>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console