Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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.


Auto Save

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.


    Demonstrates how ReactJS can be mounted to 
    multiple containers and share the same 
    state with Redux.
<div id="mood-view"></div>
<div id="mood-button"></div>


                html {
    height: 100%

body {
    align-items: center;
    display: flex;
    flex-direction: column;
    font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", sans-serif;
    height: 100%;
    justify-content: center;
    text-align: center;

.Mood__emoji {
    line-height: 4rem;
    font-size: 4rem;
    margin-bottom: .25rem;

.Mood__name {
    font-size: 1.75rem;
    margin-bottom: 2rem;

.Mood__button {
    background: #eee;
    border: 1px solid #ddd;
    cursor: pointer;
    padding: .5rem 1rem;
    font-size: .75rem;
    margin-bottom: 1rem;


                const { createStore, applyMiddleware } = Redux;
const { Provider } = ReactRedux;
const { connect } = ReactRedux;
const { combineReducers } = Redux;

// Actions
const SET_MOOD = "SET_MOOD";

function setMood() {
    const moods = [
        { name: "Happy", "emoji": "😀" }, 
        { name: "Angry", "emoji": "😠" },
        { name: "Really Angry", "emoji": "😡" },
        { name: "Sad", "emoji": "🙁" },
        { name: "Really Sad", "emoji": "☚ī¸" },
        { name: "Poop", "emoji": "💩" }
    const mood = moods[Math.floor(Math.random()*moods.length)];

    return { 
        type: SET_MOOD, 

// Reducer
const initialState = { 
    name: [ "Emoji Placeholder" ], 
    emoji: null

function mood(state = initialState, action) {
  switch(action.type) {
    case SET_MOOD:
      return action.mood;
      return state;      

// Store
const App = combineReducers({ mood });
const store = createStore(App);

// Our Pure Components
function MoodView({ mood }) {
    return (
        <div className="Mood">
            <div className="Mood__emoji">{ mood.emoji }</div>
            <div className="Mood__name">{ }</div>
function MoodButton({ onButtonClick, mood }) {
    return (
        <div className="MoodButton">
            <button className="Mood__button" onClick={ onButtonClick }>
                Random Mood - { }

// Connect our state and actions to our components
function mapStateToProps(state, ownProps) {
    return {
        mood: state.mood

function mapDispatchToProps(dispatch) {
    return {
        onButtonClick: () => dispatch(setMood())

const MoodViewConnected = connect(mapStateToProps, mapDispatchToProps)(MoodView)
const MoodButtonConnected = connect(mapStateToProps, mapDispatchToProps)(MoodButton)

// Render each connected component separatly. 
// Both components share the same state.
    <Provider store={ store }>
        <MoodViewConnected />

    <Provider store={ store }>
        <MoodButtonConnected />