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.

              link(href='https://fonts.googleapis.com/css?family=Roboto', rel='stylesheet', type='text/css')

h1 Search input + animated suggestions
h2 Animation in Sass, simple script in CoffeeScript

    input.search-input#search(type="text", placeholder="Search people")
              // Importing bourbon to make things easy: http://bourbon.io/
@import "bourbon"

// Useful mixins
@mixin border-radius($radius: 4px)
  @include prefixer(border-radius, $radius, webkit moz spec)
@mixin box-sizing($box-model)
  @include prefixer(box-sizing, $box-model, webkit moz spec)
/* General styles */

  background-color: white
  font-family: 'Roboto', Arial, sans-serif
  text-align: center
  padding-top: 30px
  font-size: 14px
  font-size: 1.5em
  color: #666666
h2, a
  font-size: 0.8em
  color: #9BC788
  color: #999
  margin-top: 40px

/* ============================ */
/* VARIABLES                    */
/* ============================ */
$color-primary: #9BC788
$search-width: 400px
$search-icon-width: 32px
$search-height: 40px
$visible-results: 5
/* ============================ */
/* SEARCH BAR                   */
/* ============================ */
  margin: 40px auto
  width: $search-width
  @include border-radius(3px)
  background-color: #f2f2f2
  height: $search-height
  position: relative
  @include box-sizing(border-box)
  float: left
  width: $search-icon-width
  height: $search-height
  color: #999
  font-size: 1.3em
  padding: 7px 15px
  @include box-sizing(border-box)
  width: $search-width - $search-icon-width
  height: $search-height
  float: right
  background-color: transparent
  border: 0px
  padding: 10px
  text-transform: uppercase
  font-family: 'Roboto', Arial, sans-serif
  font-size: 1em
  position: relative
  outline: 0px
//useful for animation
@include keyframes(fadeInTop)
    opacity: 0
    @include transform(translateY(-1.334em) translateZ(0))
    opacity: 1

@mixin fadeInTop($dur: 1s, $delay: 0s, $fill: forwards)
  @include prefixer(animation, fadeInTop $dur $delay $fill, webkit spec)

  list-style: none
  margin: 0
  padding: 0
  position: absolute
  z-index: 999
  width: $search-width - $search-icon-width
  max-height: $search-height * $visible-results
  overflow: scroll
  top: $search-height
  left: $search-icon-width
  text-align: left
    @include box-sizing(border-box)
    padding: 10px
    height: $search-height
    background-color: $color-primary
    color: white
    font-weight: bold
      background-color: darken($color-primary, 7%)
      cursor: pointer
    /* ANIMATION */
    /* remove this part if you dont like the animation */
    @for $i from 1 through $visible-results
        /* Animation */
        @include fadeInTop(0.4s, (($i - 1)/10) * 1s )
        opacity: 0
              names = [

# Match words in a collection
findAll = (wordList, collection) =>
  collection.filter (word) ->
    word = word.toLowerCase()
    wordList.some (w) -> ~word.indexOf w

# Displays results in a list
displayResults = (resultsEl, wordList) ->
  resultsEl.innerHTML = (wordList.map (w) -> '<li>'+w+'</li>').join ''

# Handle keyboard events
searchInput = document.getElementById 'search'
resultsOutput = document.getElementById 'results'
maxResults = 7

searchInput.addEventListener 'keyup', (e) =>
    value = searchInput.value.toLowerCase().split ' '
    suggested = (if value[0].length then findAll value, names else [])
    displayResults resultsOutput, suggested
🕑 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.