Sun May 10 2020
npm install hamburger-react
When using one hamburger, ~1.5 KB will be added to your bundle (min + gzip).
Visit the website for full documentation, API and examples. A basic implementation looks as follows:
import Hamburger from 'hamburger-react';
const [isOpen, setOpen] = useState(false);
<Hamburger toggled={isOpen} toggle={setOpen} />
Or without providing your own state:
<Hamburger onToggle={toggled => ...} />
Yes. Since the creation of these burgers in 2015 a lot of similar ones have appeared, with one or more of the following downsides:
It is recommended to have a tap/click area of at least 48x48 pixels. Therefore, padding will be added around the icon to create a surface of exactly this size.
Keyboard interaction is provided with the enter
key, and the icon element has the recommended accessibility attributes (such as role
). You can use the label
property to supply an ARIA label for the icon.
The icons are hooks-based, and will work with React 16.8.0 ('the one with hooks') or higher.