Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <!--
I saw an example on discord where someone wanted to know whether they should use GSAP or CSS for the navigation animation. I liked the example and tried to realize the navigation animation with tailwind.
This is the result
-->

<div x-data="lw" class="bg-neutral-950 min-h-screen grid grid-rows-[auto_1fr]">
  <header class="relative bg-neutral-950 pt-16 text-center grid grid-rows-[auto_0fr] motion-safe:transition-[grid-template-rows] motion-safe:duration-500 overflow-hidden" :class="showNavigation ? 'grid-rows-[auto_1fr]' : 'grid grid-rows-[auto_0fr]'" @click.outside="clickOutside"  @keyup.escape="clickOutside">
    <div class="absolute bottom-0 left-0 right-0 w-full h-full mx-auto bg-white translate-y-0 transform-gpu pointer-events-none" :class="getCurrentClasses"></div>

    <div class="container mx-auto relative">
      <button type="button" class="text-white font-bold hover:text-neutral-950 hover:bg-white size-24 bg-neutral-950 text-5xl mx-auto motion-safe:transition-all" :class="showNavigation ? 'text-neutral-950 bg-white' : 'bg-neutral-950 text-white'" @click="toggleNavigation" @mouseenter="toggleHoverStatus" @mouseleave="toggleHoverStatus">
        K
      </button>
    </div>
    
    <nav class="overflow-hidden relative" aria-label="Main navigation">
      <ul class="container mx-auto px-8 flex flex-col md:flex-row flex-wrap text-white w-full transform-gpu motion-safe:transition-all justify-between py-16 md:py-20 [&>li]:text-neutral-300 [&>li:hover]:text-white [&>li]:py-2" :class="showNavigation ? 'py-16 md:py-20 opacity-100 translate-x-0' : 'py-0 opacity-0 translate-y-full'">
        <li>
          <a href="!#" class="inline-flex md:flex-col justify-between items-center w-full">
            <span class="font-semibold text-2xl lg:text-4xl">Home</span>
            <span class="flex-1 h-px bg-neutral-600 mx-4 md:hidden"></span>
            <span class="text-neutral-500">Welcome</span>
          </a>
        </li>
        <li>
          <a href="!#" class="inline-flex md:flex-col justify-between items-center w-full">
            <span class="font-semibold text-2xl lg:text-4xl">Work</span>
            <span class="flex-1 h-px bg-neutral-600 mx-4 md:hidden"></span>
            <span class="text-neutral-500">What I've made</span>
          </a>
        </li>
        <li>
          <a href="!#" class="inline-flex md:flex-col justify-between items-center w-full">
            <span class="font-semibold text-2xl lg:text-4xl">Services</span>
            <span class="flex-1 h-px bg-neutral-600 mx-4 md:hidden"></span>
            <span class="text-neutral-500">What I can offer</span>
          </a>
        </li>
        <li>
          <a href="!#" class="inline-flex md:flex-col justify-between items-center w-full">
            <span class="font-semibold text-2xl lg:text-4xl">About</span>
            <span class="flex-1 h-px bg-neutral-600 mx-4 md:hidden"></span>
            <span class="text-neutral-500">Who I am</span>
          </a>
        </li>
        <li>
          <a href="!#" class="inline-flex md:flex-col items-center w-full">
            <span class="font-semibold text-2xl lg:text-4xl">Contact</span>
            <span class="flex-1 h-px bg-neutral-600 mx-4 md:hidden"></span>
            <span class="text-neutral-500">Get in touch</span>
          </a>
        </li>
      </ul>
    </nav>
  </header>

  <main class="relative flex flex-col">
    <div class="absolute top-0 left-0 right-0 mx-auto w-full h-full bg-white motion-safe:transition-all" :class="logoHoverStatus ? 'w-[calc(100%_-_4rem)] h-[calc(100%_-_2rem)]' : 'w-full h-full'">
    </div>
    <div class="container mx-auto relative text-neutral-900 text-center h-full flex flex-col items-center justify-between pt-16 px-8">
      <p class="text-2xl text-neutral-400 text-balance">UI/UX Designer & Front-End Developer</p>
      <h1 class="text-6xl md:text-8xl font-bold tracking-tighter text-balance py-[25vh]">Building for the modern web.</h1>
      <h2 class="text-2xl font-bold tracking-tight after:block after:h-24 after:w-px after:bg-neutral-950 after:mx-auto after:mt-8">View Showcace</h2>
    </div>
  </main>

</div>
              
            
!

CSS

              
                [x-cloak] { display: none !important; }


// removing scrollbar
html {
   /* webkit browser */
  &::-webkit-scrollbar {
    display: none;
  }
  /* Firefox */
  scrollbar-width: none; 
}
              
            
!

JS

              
                import Alpine from "https://esm.sh/alpinejs"

Alpine.data('lw', () => ({
  showNavigation: false,
  logoHoverStatus: false,

  toggleNavigation() {
    this.showNavigation =! this.showNavigation
  },
  
  clickOutside() {
    if (!this.showNavigation) return
    this.logoHoverStatus = false
    this.showNavigation = false
  },

  toggleHoverStatus() {
    if (this.showNavigation) return
    this.logoHoverStatus =! this.logoHoverStatus
  },
  
  getCurrentClasses() {
     if (this.logoHoverStatus) {
       return this.showNavigation ? 'w-[calc(100%_-_4rem)] translate-y-full transition-none' : 'translate-y-3/4 w-[calc(100%_-_4rem)] motion-safe:transition-all'
    } else {
      return this.showNavigation ? 'translate-y-0 motion-safe:transition-all delay-500' : 'translate-y-0 motion-safe:transition-all'
    }
  }
  
}))

Alpine.start()
              
            
!
999px

Console