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="app">
  <router-link to="/">Home</router-link>
  <router-link to="/product/red-dress">/product/red-dress</router-link>
  <router-link to="/product/blue-dress">/product/blue-dress</router-link>
  <transition name="slide-left">
    <router-view class="view" :key="$route.fullPath" />



                #app {
  text-align: center;    
.view {
  position: absolute;
  width: 100%;
  transition: transform 1000ms linear;
.slide-left-enter, .slide-right-leave-active {
  transform: translate3d(300px, 0, 0);
.slide-left-leave-active, .slide-right-enter {
  transform: translate3d(-300px, 0, 0);



                // Empty store we can register our modules into
const store = new Vuex.Store({});

// Module to be used for the /product/:slug route
const productModule = {
  namespaced: true,
  state: {
    slug: null,
  mutations: {
    setSlug(state, slug) {
      state.slug = slug;

// Homepage component
const HomeRouteComponent = {
  render(h) {
    return h('h1', 'Homepage');

// This is the vue-router route-level component rendered for 
// a given product based on the slug, i.e., /product/red-dress 
// or /product/blue-dress
const ProductRouteComponent = {
  // Each instance of this rotue will use the following namespaced 
  // vuex module
  vuex: {
    moduleName: 'product',
    module: productModule,
  // This method will load data for the given route into the 
  // namespaced vuex module
  async fetchData(route, store) {
    // Simulate something async
    await new Promise(r => setTimeout(r, 100));
    store.commit('product/setSlug', route.params.slug);
  computed: {
    ...Vuex.mapState('product', {
      slug: state => state.slug,
  render(h) {
    return h('h1', `Slug: ${this.slug}`);          

const router = new VueRouter({
  routes: [{ 
    path: '/',
    component: HomeRouteComponent,
  }, {
    path: '/product/:slug', 
    component: ProductRouteComponent,

router.onReady(() => {
  router.beforeResolve(async (to, from, next) => {
    // Note this is a simplistic approach for example purposes.  In 
    // a real-world app you will need to do some comparisons between 
    // prior routes and avoid double-registering modules
    // Find out the components that match our destination route.  This 
    // will only be more than one component if you re using nested routes
    const matched = router.getMatchedComponents(to);

    // Register moules for each destination component
      .filter(cmp => cmp.vuex)
      .forEach(cmp => store.registerModule(
    // Execute fetchData for each destination component
    const promises = matched
      .filter(cmp => cmp.fetchData)
      .map(cmp => cmp.fetchData(to, store));

    await Promise.all(promises);

new Vue({
  el: '#app',