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.


                <div id="root"></div>



.animated_div {
    width: 60px;
    height: 40px;
    background: #92B901;
    color: #ffffff;
    position: absolute;
    font-weight: bold;
    font-size: 15px;
    padding: 10px;
    float: left;
    margin: 5px;
    -webkit-transition: -webkit-transform 1s,opacity 1s,background 1s,width 1s,height 1s,font-size 1s;
    -webkit-border-radius: 5px;
    -o-transition-property: width,height,-o-transform,background,font-size,opacity;
    -o-transition-duration: 1s,1s,1s,1s,1s,1s;
    -moz-transition-property: width,height,-o-transform,background,font-size,opacity;
    -moz-transition-duration: 1s,1s,1s,1s,1s,1s;
    transition-property: width,height,transform,background,font-size,opacity;
    transition-duration: 1s,1s,1s,1s,1s,1s;
    border-radius: 5px;
    opacity: 0.4;

.potato {
    opacity: 1;
    background: #1ec7e6;
    width: 130px;
    height: 80px;
    font-size: 35px;


                const App = props => {
  const [selected, setSelected] = React.useState(0);
  const nextAnecdote = () =>
    setSelected(Math.round(Math.random() * (props.anecdotes.length - 1)));
  const [votes, setVotes] = React.useState([0, 0, 0, 0, 0, 0]);
  let popularAnecdote = "";
  let newMax = 0;
  let i = 0;
  for (i = 0; i < votes.length; i++) {
    if (votes[i] >= newMax) {
      newMax = votes[i];
      popularAnecdote = anecdotes[i];
  function handleVote() {
    const newVotes = [...votes]
    newVotes[selected] = newVotes[selected] + 1

  return (
      <button onClick={nextAnecdote}> next anecdote </button>

      <button onClick={handleVote}> vote </button>

      <p> Has {votes[selected]} votes</p>
      <h1>Most Votes</h1>


const anecdotes = [
  "If it hurts, do it more often",

  "Adding manpower to a late software project makes it later!",

  "The first 90 percent of the code accounts for the first 90 percent of the development time...The remaining 10 percent of the code accounts for the other 90 percent of the development time.",

  "Any fool can write code that a computer can understand. Good programmers write code that humans can understand.",

  "Premature optimization is the root of all evil.",

  "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."

<App anecdotes={anecdotes} />,