Navigation burgericonanimated
Animated Burger Menu
CSS burger icon that morphs into an
Preview
Usage
Copy the full block below to use this component with its imports.
astro
---
import { AnimatedBurgerMenu } from 'astro-component-kit';
---
<BurgerMorphIcon>Content</BurgerMorphIcon> ---
import { AnimatedBurgerMenu } from 'astro-component-kit';
---
<BurgerMorphIcon>Content</BurgerMorphIcon> Manual Installation
If you are not using the npm package, create a new file src/components/lib/AnimatedBurgerMenu.astro and paste the following code:
astro
---
---
<button class="burger" onclick="this.classList.toggle('active')">
<span></span><span></span><span></span>
</button>
<style>
.burger { background: none; border: none; width: 30px; height: 24px; cursor: pointer; display: flex; flex-direction: column; justify-content: space-between; }
.burger span { width: 100%; height: 3px; background: #fff; border-radius: 2px; transition: 0.4s; }
.burger.active span:nth-child(1) { transform: translateY(10.5px) rotate(45deg); }
.burger.active span:nth-child(2) { opacity: 0; }
.burger.active span:nth-child(3) { transform: translateY(-10.5px) rotate(-45deg); }
</style> ---
---
<button class="burger" onclick="this.classList.toggle('active')">
<span></span><span></span><span></span>
</button>
<style>
.burger { background: none; border: none; width: 30px; height: 24px; cursor: pointer; display: flex; flex-direction: column; justify-content: space-between; }
.burger span { width: 100%; height: 3px; background: #fff; border-radius: 2px; transition: 0.4s; }
.burger.active span:nth-child(1) { transform: translateY(10.5px) rotate(45deg); }
.burger.active span:nth-child(2) { opacity: 0; }
.burger.active span:nth-child(3) { transform: translateY(-10.5px) rotate(-45deg); }
</style>
Quick Info
- Category
- Navigation
- Filename
AnimatedBurgerMenu.astro- Dependencies
- None — pure Astro + CSS
- Tags
- burgericonanimated