123

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

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 id="app">
	<div class="title">
		<h1>Clip-Path: Complex Shapes</h1>
	</div>
	<div class="panel">
		<label for="shapes">Animations</label>
		<select id="shapes" v-model="currentTransition">
			<option value="chevron">chevron</option>
			<option value="spiral">spiral</option>
      <option value="slots">slots</option>
      <option value="shutters">shutters</option>
      <option value="star">star</option>
		</select>
		
		<label for="modes">Modes</label>
		<select id="modes" v-model="mode">
			<option value="">none</option>
			<option value="out-in">out-in</option>
			<option value="in-out">in-out</option>
		</select>
		
		<button @click="transition">transition</button>
	</div>
	<div class="boxes">
		<transition :name="currentTransition" :mode="mode">
      <box1 v-if="box1"></box1>
      <box2 v-else></box2>
    </transition>		
	</div>
	<div class="example">
		<transition name="fade" mode="out-in">
			<div class="container" :key="currentTransition" v-html="descriptions[currentTransition]"></div>
		</transition>
	</div>
	<div class="instructions">
		<ul>
			<li>Choose from four different types of clip-path animations in the "Animations" dropdown.</li>
			<li>Choose from the different Vue Transition Component modes in the "Modes" dropdown that control the order of the boxes transitioning.</li>
			<li>Click the "Transition" button to see the selected options being animated.</li>
		</ul>
	</div>
</div>

            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Luckiest+Guy');

html {
  box-sizing: border-box;
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
}
*, *:before, *:after {
  box-sizing: inherit;
}
html,
body {
  background-color: #1d1e22;
  margin: 0;
  padding: 0;
}
body {
	align-items: center;
	display: flex;
	height: 100vh;
	justify-content: center;
}

#app {
	display: grid;
  grid-template-columns: 150px 300px 350px;
  grid-gap: 20px;
	
	.title {
		color: #FFF;
		grid-column: 1 / 4;
	
		h1 {
			font-size: 20px;
			font-weight: bold;
		}
	}
	
	.instructions {
		color: #FFF;
		grid-column: 1 / 4;
		
		ul {
			list-style: disc;
		}
		li {
			margin-bottom: 10px;
		}
	}
}


.panel {
	display: flex;
	flex-direction: column;
	
	label {
		color: #fff;
	}
	
	button,
	select {
		font-size: 18px;
		margin: 10px 0;
		padding: 5px 0;
	}
}

.boxes {
  align-items: center;
  background-color: #C5C5C5;
  border: 3px solid #FFF;
  display: flex;
  height: 300px;
  justify-content: center;
  width: 300px;
  
  &::before {
    background-color: darken(#C5C5C5, 10%);
    content: '';
    display: block;
    height: 200px;
    position: absolute;
    width: 200px;
  }
  &::after {
    align-items: center;
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    content: "Sorry!\A\AThis browser doesn't support this type of clip-path animations!";
    display: flex;
    height: 200px;
    position: absolute;
    text-align: center;
    white-space: pre-wrap;
    width: 200px;
  }
	
	.box {
		align-items: center;
		background-color: #307B21;
		color: #fff;
		display: flex;
		font-family: 'Luckiest Guy';
		font-size: 60px;
		height: 200px;
		justify-content: center;
		position: absolute;
		width: 200px;
	}
	.box2 {
		background-color: #4371AD;
	}
}
@supports(clip-path: polygon(0% 0%, 10% 10%, 20% 20%)) {
  .boxes::after {
    display: none;
  }
}

.example {
	color: #FFF;
	
	p {
		margin-bottom: 10px;
	}
  .container {
    width: 350px;
  }
}

.fade-enter,
.fade-leave-to { opacity: 0; }
.fade-enter-active,
.fade-leave-active { transition: 500ms; position: absolute; }

.chevron-enter-active { animation: 1s chevron-enter; }
.chevron-leave-active { animation: 1s chevron-leave; }
@keyframes chevron-enter {
  0% { clip-path: polygon(-25% 0%, 0% 50%, -25% 100%, -100% 100%, -75% 50%, -100% 0%); }
  75% { clip-path: polygon(75% 0%, 100% 50%, 75% 100%, 0% 100%, 25% 50%, 0% 0%); }
  100% { clip-path: polygon(100% 0%, 100% 50%, 100% 100%, 0% 100%, 0% 50%, 0% 0%); }
}
@keyframes chevron-leave {
  0% { clip-path: polygon(100% 0%, 100% 50%, 100% 100%, 0% 100%, 0% 50%, 0% 0%); }
  25% { clip-path: polygon(75% 0%, 100% 50%, 75% 100%, 0% 100%, 25% 50%, 0% 0%); }
  100% { clip-path: polygon(175% 0%, 200% 50%, 175% 100%, 100% 100%, 125% 50%, 100% 0%) }
}

.spiral-enter-active { animation: 1s spiral reverse; }
.spiral-leave-active { animation: 1s spiral; }
@keyframes spiral {  
  0% { clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 25%, 75% 25%, 75% 75%, 25% 75%, 25% 50%, 50% 50%, 25% 50%, 25% 75%, 75% 75%, 75% 25%, 0% 25%); }
  14.25% { clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 25%, 75% 25%, 75% 75%, 50% 75%, 50% 50%, 50% 50%, 25% 50%, 25% 75%, 75% 75%, 75% 25%, 0% 25%); }
  28.5% { clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 25%, 75% 25%, 75% 50%, 50% 50%, 50% 50%, 50% 50%, 25% 50%, 25% 75%, 75% 75%, 75% 25%, 0% 25%); }
  42.75% { clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 25%, 25% 25%, 25% 50%, 25% 50%, 25% 50%, 25% 50%, 25% 50%, 25% 75%, 75% 75%, 75% 25%, 0% 25%); }
  57% { clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 75%, 25% 75%, 25% 75%, 25% 75%, 25% 75%, 25% 75%, 25% 75%, 25% 75%, 75% 75%, 75% 25%, 0% 25%); }
  71.25% { clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 75% 100%, 75% 75%, 75% 75%, 75% 75%, 75% 75%, 75% 75%, 75% 75%, 75% 75%, 75% 75%, 75% 75%, 75% 25%, 0% 25%); }
  85.5% { clip-path: polygon(0% 0%, 100% 0%, 100% 25%, 75% 25%, 75% 25%, 75% 25%, 75% 25%, 75% 25%, 75% 25%, 75% 25%, 75% 25%, 75% 25%, 75% 25%, 75% 25%, 0% 25%); }
  100% {clip-path: polygon(0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 25%, 0% 25%, 0% 25%, 0% 25%, 0% 25%, 0% 25%, 0% 25%); }
}

.slots-enter-active { animation: 1s slots reverse; }
.slots-leave-active { animation: 1s slots; }
@keyframes slots {
  0% {
    clip-path: polygon(0% 0%, 14% 0%, 14% 0%, 28% 0%, 28% 0%, 42% 0%, 42% 0%, 56% 0%, 56% 0%, 70% 0%, 70% 0%, 84% 0%, 84% 0%, 100% 0, 100% 100%, 0% 100%);
  }
  50% {
    clip-path: polygon(0% 0%, 14% 0%, 14% 100%, 28% 100%, 28% 0%, 42% 0%, 42% 100%, 56% 100%, 56% 0%, 70% 0%, 70% 100%, 84% 100%, 84% 0%, 100% 0, 100% 100%, 0% 100%);
  }
  100% {
    clip-path: polygon(0% 100%, 14% 100%, 14% 100%, 28% 100%, 28% 100%, 42% 100%, 42% 100%, 56% 100%, 56% 100%, 70% 100%, 70% 100%, 84% 100%, 84% 100%, 100% 100%, 100% 100%, 0% 100%);
  }
}

.shutters-enter-active { animation: 1s shutters reverse; }
.shutters-leave-active { animation: 1s shutters; }
@keyframes shutters {
  0% {
    clip-path: polygon(0% 0%, 20% 0%, 20% 100%, 20% 100%, 20% 0%, 40% 0%, 40% 100%, 40% 100%, 40% 0%, 60% 0%, 60% 100%, 60% 100%, 60% 0%, 80% 0%, 80% 100%, 80% 100%, 80% 0%, 100% 0%, 100% 100%, 0% 100%);
  }
  100% {
    clip-path: polygon(20% 0%, 20% 0%, 20% 100%, 40% 100%, 40% 0%, 40% 0%, 40% 100%, 60% 100%, 60% 0%, 60% 0%, 60% 100%, 80% 100%, 80% 0%, 80% 0%, 80% 100%, 100% 100%, 100% 0%, 100% 0%, 100% 100%, 20% 100%);
  }
}

.star-enter-active { animation: 1s star reverse; }
.star-leave-active { animation: 1s star; }
@keyframes star {
  0% {
    clip-path: polygon(0% 0%, 50% 0%, 100% 0%, 100% 50%, 100% 100%, 50% 100%, 0% 100%, 0% 50%);
  }
  50% {
    clip-path: polygon(0% 0%, 50% 100%, 100% 0%, 0% 50%, 100% 100%, 50% 0%, 0% 100%, 100% 50%);
  }
  100% {
    clip-path: polygon(50% 50%, 50% 100%, 50% 50%, 0% 50%, 50% 50%, 50% 0%, 50% 50%, 100% 50%);
  }
}
            
          
!
            
              Vue.component('box1', {
	template: '<div class="box box1">box1</div>'
});
Vue.component('box2', {
	template: '<div class="box box2">box2</div>'
});

new Vue({
  el: "#app",
  data: {
  	box1: true,
    currentTransition: 'chevron',
    mode: 'out-in',
		descriptions: {
			chevron: '<p>The chevron animation uses the polygon shape with six vertices.</p><p>The leave transition starts with all the vertices forming a square to cover the box. The next step of the animation animates three of the points into a chevron pointing to the right. The animation completes with moving all six points out of the box area to the right.</p><p>The enter transition does the same in reverse; the chevron slides in from the left, stops, and then the three vertices animate the shape back into a square.</p>',
			spiral: '<p>The sprial animation uses the polygon shape with fifteen vertices arranged in a spiral and eight keyframes in the animation.</p><p>In the leave transition animates the spiral so that at each keyframe the vertices are moved on top of neighboring vertices. Over time this gives the appearance of a spiral unwinding to the upper left of the box area.</p><p>The enter transition does the same in reverse; starting in the upper left and winding inward to the center.</p>',
      slots: '<p>The slots animation uses the polygon shape with sixteen vertices arranged in a series of vertical lines of overlapping vertices forming slots.</p><p>The leave transition first animates every other vertical slot from the top down to the bottom. The next keyframe of the animation animates the leftover slots downard in the same motion. This provides the appearance of alternating slots disappearing off the bottom of the box area.</p><p>The enter transition does the same in reverse; alternating slots animate upwards to the top of the box area.</p>',
      shutters: '<p>The shutters animation uses the polygon shape with twenty vertices arranged in a series of vertical lines of overlapping vertices forming vertical rectangles.</p><p>The leave transition animates the left side of each vertical rectangle to the right on top of the vertices that make up the right side of the rectangle; essentially making them disappear.</p><p>The enter transition does the same in reverse; the left side of the vertical rectangles start on top of the vertices of the right side. They are then animated back to the left to reform the vertical rectangles.</p>',
      star: '<p>The star animation uses the polygon shape with eight vertices arranged in a square.</p><p>The leave animation moves the side vertices to their opposite sides in the first keyframe to make a star. Then it moves the corners to the center in the third keyframe to collpase the star.</p><p>The enter animation does the same in reverse.</p>'
		}
  },
  methods: {
  	transition () {
    	this.box1 = !this.box1;
    }
  }
})
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console