Hamburgers is a collection of tasty CSS-animated hamburger icons. Also included is the source as a Sass library. It’s modular and customizable, so cook up your own hamburger.
<head>of your site:
You can use
<div>s if you insist, but they’re not accessible as a menu button.
Here’s the list of hamburger-type classes you can choose from:
hamburger--3dx hamburger--3dx-r hamburger--3dy hamburger--3dy-r hamburger--3dxy hamburger--3dxy-r hamburger--arrow hamburger--arrow-r hamburger--arrowalt hamburger--arrowalt-r hamburger--arrowturn hamburger--arrowturn-r hamburger--boring hamburger--collapse hamburger--collapse-r hamburger--elastic hamburger--elastic-r hamburger--emphatic hamburger--emphatic-r hamburger--minus hamburger--slider hamburger--slider-r hamburger--spin hamburger--spin-r hamburger--spring hamburger--spring-r hamburger--stand hamburger--stand-r hamburger--squeeze hamburger--vortex hamburger--vortex-r
-r classes are reverse variants (e.g.
hamburger--spin spins clockwise whereas
hamburger--spin-r spins counterclockwise.
.scss source files are available if you use Sass as your CSS precompiler. It’s customizable and modular.
npm install hamburgers yarn add hamburgers bower install css-hamburgers
Or to manually install it, download and unzip the source files, then copy the files from the
_sass/hamburgers directory into your project.
hamburgers.scssfile in your Sass manifest file:
* Be sure to run the CSS through Autoprefixer since the Sass doesn’t account for vendor prefixes.
** More information on why Sass’s native
@import + why you should ditch Sprockets directives altogether.
To override default settings, declare them before importing Hamburgers:
You can also create a separate file (e.g.
hamburgers-settings.scss) with those declarations, then import it before Hamburgers:
Here is the full list of default settings (found in
;;;;;;;;;;// To use CSS filters as the hover effect instead of opacity,// set $hamburger-hover-use-filter as true and// change the value of $hamburger-hover-filter accordingly.;;// Remove or comment out the hamburger types you don’t want// or need, so they get excluded from the compiled CSS.;
Wanna work with
rems instead of
px? Just change all the
px values to the unit of your choice. Note: Be consistent (all
px or all
ems), otherwise it may break—the math behind the customization will fail if it attempts to perform operations with values of different units.
types/ and customize to your heart’s content. Fair warning: It‘s pretty delicate and may break, especially if you tweak the animations themselves.
Hamburger menu icons can be useful in the right context, but they’re not the most accessible.
ARIA will help make it accessible to people with disabilities.
<!--navigation goes here-->
aria-expanded attribute being set to
false, as this will indicate to visually impaired users whether the menu is opened or closed.
The hamburger button belongs inside the
<nav> so that assistive technologies will be able to locate the navigation, and to allow these users to easily locatate the hamburger button, without having to search up and down the DOM, once they realize they've found themselves in an empty navigation.
If you insist on using
<div>s, by default they’re not focusable (i.e. via keyboard or assistive technology). Add the
tabindex attribute alongside ARIA. You will also need to recreate expected keyboard functionality for these
<!--navigation goes here-->
A label will help make it more obvious that it toggles a menu.
Animations use CSS3 3D transforms (
translate3d whenever possible for GPU acceleration), which is supported by most browsers (not supported by IE9 and older and Opera Mini). For detailed browser support, check caniuse.com.