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.

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.


                <div class="container">
  <h3 class="title">
    Simple Image Carousel
  <p class="para">Impliments <code>&lt;Swipeable/&gt;</code> component to track touch/swipe events.</p>
  <div class="title">
    <a href=""></a>
  <div id="mainApp"></div>


  margin: .5rem
  max-width: 400px

  padding-bottom: .25em
  padding-bottom: 0
  padding: 1em
  display: inline-block;
  border: 2px solid gray;
  padding: 5px;
  background-color: transparent;
  border: 0;
  cursor: pointer;
  float: right!important;
  float: left!important;


                'use strict';
// import React from 'react';
// import Swipeable from 'react-swipeable';

const IMG_1 = ``;
const IMG_2 = ``;
const IMG_3 = ``;
const IMG_4 = ``;
const IMG_5 = ``;
const IMAGES = [IMG_1, IMG_2, IMG_3, IMG_4, IMG_5];
const IMG_WIDTH = "342px";
const IMG_HEIGHT = "249px";

const RIGHT = '-1';
const LEFT = '+1';

const buttonStyles = {
  height: IMG_HEIGHT,
  color: "#eeeeee",
  fontSize: "2em",

class SimpleCarousel extends React.Component {
  constructor(props, context) {
    super(props, context);
    this.state = { imageIdx: 0 };

  onSwiped(direction) {
    const change = direction === RIGHT ? RIGHT : LEFT;
    const adjustedIdx = this.state.imageIdx + Number(change);
    let newIdx;
    if (adjustedIdx >= IMAGES.length) {
      newIdx = 0;
    } else if (adjustedIdx < 0) {
      newIdx = IMAGES.length - 1
    } else {
      newIdx = adjustedIdx;
    this.setState({ imageIdx: newIdx });

  render() {
    const { imageIdx = 0 } = this.state;
    const imageStyles = {
      width: IMG_WIDTH,
      height: IMG_HEIGHT,
      backgroundImage: `url(${IMAGES[imageIdx]})`
    return (
      <div className="swipeContainer">
        <div>Image: {imageIdx + 1}</div>
          style={{ touchAction: 'none' }}
          <div style={imageStyles} >
              className="hollow float-left"
              className="hollow float-right"
ReactDOM.render(<SimpleCarousel/>, document.getElementById("mainApp"));

function preload(...images) {
  return images.reduce((acc, img)=>{
    let newImage = new Image();
    newImage.src = img;
    return acc;
  }, []);
preload.apply(null, IMAGES);