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.


                h1.header SLIDE FILTER
		span.filter__item.filter__item--active week
		span.filter__item month
		span.filter__item year


                $fontPrimary: #a3a7c6
$fontFamily: 'Open Sans Condensed', sans-serif

	background: #2d3047

	box-sizing: border-box
	margin: 0
	padding: 0

	box-sizing: inherit

	color: $fontPrimary
	font-family: $fontFamily
	text-align: center
	font-size: 4rem

	display: flex
	justify-content: center
	align-items: center
	width: 500px
	height: 200px
	margin: 0 auto

	width: 100%
	height: 100%
	position: relative
	width: 320px
	height: 60px
	border-radius: 100px
	background: #373b56
	display: flex
	justify-content: space-between
	align-items: center

	width: 33.33%
	font-family: $fontFamily
	font-size: 0.9rem
	text-transform: uppercase
	letter-spacing: 2px
	text-align: center
	color: $fontPrimary
	cursor: pointer
	transition: color 700ms ease
	z-index: 2
	color: #fff
	height: calc(100% - 10px)
	width: calc(33.33% - 10px)
	border-radius: 100px
	background: #5a6be8
	position: absolute
	top: 5px
	left: 5px


                const filterSwitch = document.querySelector('.filter__switch')

// event delegator for .filter__items
document.querySelector('.filter').addEventListener('click', e => {

  const el =

	// if clicked element is an inactive .filter__item
  if (el.classList.contains('filter__item') && !el.classList.contains('filter__item--active')) {
    const filterItemData = el.getBoundingClientRect()
    const switchData = filterSwitch.getBoundingClientRect()
    const origin = document.querySelector('.filter__item').getBoundingClientRect().x + 5

		// calculate new x coordinate for switch
    const midPoint = filterItemData.x + (filterItemData.width / 2)
    const newSwitchX = midPoint - (switchData.width / 2)

		// Using the Web Animations API
    const keyframes = [
      { transform: `translateX(${switchData.x - origin}px)`},
      { transform: `translateX(${newSwitchX - origin}px)`}

    const options = {
      duration: 300,
      easing: 'cubic-bezier(0.42, 0, 0.58, 1)',
      fill: 'forwards'

    filterSwitch.animate(keyframes, options)
		// update active .filter__item