Tasty CSS-animated Hamburgers
The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:
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.
You can use
s if you insist, but they’re not accessible as a menu button.
- Append the class name of the type of hamburger you’re craving:
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
Note:-rclasses are reverse variants (e.g.hamburger--spinspins clockwise whereashamburger--spin-rspins counterclockwise.
- Trigger the active state by appending class nameis-active:
Sass.scsssource 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/hamburgersdirectory into your project.
- Import thehamburgers.scssfile in your Sass manifest file:@import "path/to/hamburgers";
- Customize your hamburger and/or remove any types you don’t want inhamburgers.scss.
- Compile your Sass*, and voila!
* Be sure to run the CSS through Autoprefixer since the Sass doesn’t account for vendor prefixes.
Install for Ruby on Rails
- Add Hamburgers to your Gemfile.gem 'hamburgers'
- Runbundle install.
- Include Hamburgers by using Sass’s native@import**:// application.scss @import "hamburgers";
** More information on why Sass’s native@import+ why you should ditch Sprockets directives altogether.
To override default settings, declare them before importing Hamburgers:$hamburger-padding-x: 20px; $hamburger-padding-y: 15px; $hamburger-types : (collapse);
You can also create a separate file (e.g.hamburgers-settings.scss) with those declarations, then import it before Hamburgers:@import "hamburgers-settings" @import "hamburgers";
Here is the full list of default settings (found in_sass/hamburgers/hamburgers.scss);$hamburger-padding-x : 15px; $hamburger-padding-y : 15px; $hamburger-layer-width : 40px; $hamburger-layer-height : 4px; $hamburger-layer-spacing : 6px; $hamburger-layer-color : #000; $hamburger-layer-border-radius : 4px; $hamburger-hover-opacity : 0.7; $hamburger-active-layer-color : $hamburger-layer-color; $hamburger-active-hover-opacity: $hamburger-hover-opacity;
// 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. $hamburger-hover-use-filter : false; $hamburger-hover-filter : opacity(50%); $hamburger-active-hover-filter: $hamburger-hover-filter;
// Remove or comment out the hamburger types you don’t want // or need, so they get excluded from the compiled CSS. $hamburger-types: ( 3dx, 3dx-r, 3dy, 3dy-r, 3dxy, 3dxy-r, arrow, arrow-r, arrowalt, arrowalt-r, arrowturn, arrowturn-r, boring, collapse, collapse-r, elastic, elastic-r, emphatic, emphatic-r, minus, slider, slider-r, spring, spring-r, stand, stand-r, spin, spin-r, squeeze, vortex, vortex-r );
Wanna work withemsorremsinstead ofpx? Just change all thepxvalues to the unit of your choice. Note: Be consistent (allpxor allems), otherwise it may break—the math behind the customization will fail if it attempts to perform operations with values of different units.
Dig into_base.scssortypes/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.
The hamburger button belongs inside theso 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.
A label will help make it more obvious that it toggles a menu.Menu
Animations use CSS3 3D transforms (translate3dwhenever 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.