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

+ add another resource


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


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.


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.


                <h1>Flickity - custom navigation UI with vanilla JS</h1>

<div class="carousel">
  <div class="carousel-cell"></div>
  <div class="carousel-cell"></div>
  <div class="carousel-cell"></div>
  <div class="carousel-cell"></div>
  <div class="carousel-cell"></div>

<div class="button-row">
  <button class="button button--previous">&larr;</button>
  <div class="button-group button-group--cells">
    <button class="button is-selected">1</button>
    <button class="button">2</button>
    <button class="button">3</button>
    <button class="button">4</button>
    <button class="button">5</button>
  <button class="button button--next">&rarr;</button>



                /* external css: flickity.css */

* { box-sizing: border-box; }

body { font-family: sans-serif; }

.carousel {
  background: #FAFAFA;
  margin-bottom: 20px;

.carousel-cell {
  width: 66%;
  height: 200px;
  margin-right: 10px;
  background: #8C8;
  border-radius: 5px;
  counter-increment: carousel-cell;

/* cell number */
.carousel-cell:before {
  display: block;
  text-align: center;
  content: counter(carousel-cell);
  line-height: 200px;
  font-size: 80px;
  color: white;

.button {
  display: inline-block;
  padding: 10px 22px;
  font-size: 18px;
  border: 1px solid #DDD;
  border-radius: 6px;
  background-color: #FAFAFA;
  background-image: linear-gradient( hsla(0, 0%, 0%, 0), hsla(0, 0%, 0%, 0.1) )

.button:hover {
  background-color: white;
  border-color: #BBB;
  cursor: pointer;

.button:focus {
  outline: thin dotted;
  outline: 5px auto -webkit-focus-ring-color;
  outline-offset: -2px;
  background-color: white;

.button:active {
  background-color: #EEE;
  box-shadow: inset 0 2px 10px hsla(0, 0%, 0%, 0.3);
} {
  background-color: #09F;
  color: white;

/* ---- button-group ---- */

.button-group {
  display: inline-block;
  vertical-align: bottom;

.button-group:after {
  content: '';
  display: block;
  clear: both;

.button-group .button {
  float: left;
  border-radius: 0;
  border-right-width: 0;

.button-group .button:first-child {
  border-radius: 6px 0 0 6px;

.button-group .button:last-child {
  border-radius: 0 6px 6px 0;
  border-right-width: 1px;

/* ---- button-row ---- */

.button-row {
  text-align: center;



                // external js: flickity.pkgd.js

var utils = window.fizzyUIUtils;

var carousel = document.querySelector('.carousel');
var flkty = new Flickity( carousel, {
  prevNextButtons: false,
  pageDots: false
// elements
var cellsButtonGroup = document.querySelector('.button-group--cells');
var cellsButtons = utils.makeArray( cellsButtonGroup.children );

// update buttons on select
flkty.on( 'select', function() {
  var previousSelectedButton = cellsButtonGroup.querySelector('.is-selected');
  var selectedButton = cellsButtonGroup.children[ flkty.selectedIndex ];

// cell select
cellsButtonGroup.addEventListener( 'click', function( event ) {
  if ( !matchesSelector(, '.button' ) ) {
  var index = cellsButtons.indexOf( ); index );
// previous
var previousButton = document.querySelector('.button--previous');
previousButton.addEventListener( 'click', function() {
// next
var nextButton = document.querySelector('.button--next');
nextButton.addEventListener( 'click', function() {;