Navigationburgericonanimated
Animated Burger Menu
Hamburger icon with morphing transition to close X.
Live Preview
Usage
Copy and paste this code into your React component:
tsx
import { BurgerMorphIcon } from 'react-component-kit-ui/navigation';
<BurgerMorphIcon>Content</BurgerMorphIcon>Manual Installation
If you are not using the npm package, create a new file and paste the following code: src/components/BurgerMorphIcon.tsx + BurgerMorphIcon.css:
BurgerMorphIcon.tsx
'use client';
import './BurgerMorphIcon.css';
// TODO(port): inline handler onClick="this.classList.toggle('active')"
/** BurgerMorphIcon โ ported from astro-component-kit. */
export interface BurgerMorphIconProps {
}
export function BurgerMorphIcon({}: BurgerMorphIconProps) {
return (
<>
<button className="burger" data-rk-641974="">
<span data-rk-641974=""></span><span data-rk-641974=""></span><span data-rk-641974=""></span>
</button>
</>
);
}
export default BurgerMorphIcon;BurgerMorphIcon.css
/* BurgerMorphIcon โ ported from astro-component-kit (navigation/BurgerMorphIcon.astro) */
.burger:where([data-rk-641974]) { background: none; border: none; width: 30px; height: 24px; cursor: pointer; display: flex; flex-direction: column; justify-content: space-between; }
.burger:where([data-rk-641974]) span:where([data-rk-641974]) { width: 100%; height: 3px; background: #fff; border-radius: 2px; transition: 0.4s; }
.burger.active:where([data-rk-641974]) span:nth-child(1):where([data-rk-641974]) { transform: translateY(10.5px) rotate(45deg); }
.burger.active:where([data-rk-641974]) span:nth-child(2):where([data-rk-641974]) { opacity: 0; }
.burger.active:where([data-rk-641974]) span:nth-child(3):where([data-rk-641974]) { transform: translateY(-10.5px) rotate(-45deg); }Quick Info
- Category
- Navigation
- Filename
BurgerMorphIcon.tsx- Dependencies
- None โ pure React + CSS
- Tags
- burgericonanimated